Hands-On Exercise 10

Author

Henry Low

Published

October 18, 2024

Modified

October 19, 2024

Data Sources

(saved under ‘data’ folder)

Data Source Description
BusStop LTA DataMall A point representation to indicate the position where buses should stop to pick up or drop off passengers.
MPSZ-2019 data.gov.sg Sub-zone boundary of URA Master Plan 2019
origin_destination_bus_202409 LTA DataMall Passenger volume by origin destination bus stops

The passenger volume by origin destination bus stops is slightly more tricky to obtain given that it is a dynamic dataset. Users are required to go through the following:

  1. Request for API access at LTA DataMall
  2. LTA DataMall will send an email with the user’s API Account Key
  3. Now, I can simply use packages such as httr and jsonlite to make an API request
  4. The url from the response will be used to download the data, unzipped into the relevant folder.

# Load required packages
pacman::p_load(httr, jsonlite)

# Url of datamall
url <- "https://datamall2.mytransport.sg/ltaodataservice/PV/ODBus"

# Update query params and header
query_params <- list(Date = "202409") # Replace date as required
headers <- httr::add_headers(
  AccountKey = "Replace_with_AccountKey"
)

# Make the GET request
response <- httr::GET(url, query = query_params, headers)
# Parse the response if it's in JSON
if (status_code(response) == 200) {
  content <- content(response, "text")
  json_data <- fromJSON(content)
  
  # Assuming the response contains a field 'zip_url' with the file URL
  zip_url <- json_data$value$Link
  
  # Download the ZIP file
  download.file(zip_url, destfile = "data.zip", mode = "wb")
  
  # Unzip the file to a directory
  unzip("data.zip", exdir = "data/aspatial")
  
  # Optionally, list the contents of the unzipped directory
  list.files("unzipped_data")
  
  # Delete the ZIP file after unzipping
  unlink("data.zip")
}

Chapter 15: Processing and Visualising Flow Data

15.1 Setting Up

Spatial interaction represent the flow of people, material, or information between locations in geographical space. It encompasses everything from freight shipments, energy flows, and the global trade in rare antiquities, to flight schedules, rush hour woes, and pedestrian foot traffic.

Each spatial interaction, as an analogy for a set of movements, is composed of a discrete origin/destination pair. Each pair can be represented as a cell in a matrix where rows are related to the locations (centroids) of origin, while columns are related to locations (centroids) of destination. Such a matrix is commonly known as an origin/destination matrix, or a spatial interaction matrix.

The goal of this exercise is to:

  • to import and extract OD data for a selected time interval,
  • to import and save geospatial data (i.e. bus stops and mpsz) into sf tibble data frame objects,
  • to populate planning subzone code into bus stops sf tibble data frame,
  • to construct desire lines geospatial data from the OD data, and
  • to visualise passenger volume by origin and destination bus stops by using the desire lines data.

15.1.1 Loading the R packages

-sf package to perform geospatial wrangling tasks 
-sp package to calculate spatial distance 
- DT package to visualize results in well-formatted tables 
- tmap package for plotting tasks 
- performance package for model metrics comparison 
- ggpubr package for custom ggplots 
-tidyverse and reshape2 package for reading csv files, dataframe processing tasks 

pacman::p_load(tmap, sf, sp, DT, stplanr, tidyverse, reshape2, performance, ggpubr)

15.1.2 Importing Aspatial Data

First, I will import the passenger volume by origin destination bus stops dataset which was downloaded via the API call. Then i’ll use glimpse() to check it.

# Load OD dataset
odbus <- read_csv("data/aspatial/origin_destination_bus_202409.csv")
Rows: 5721503 Columns: 7
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (5): YEAR_MONTH, DAY_TYPE, PT_TYPE, ORIGIN_PT_CODE, DESTINATION_PT_CODE
dbl (2): TIME_PER_HOUR, TOTAL_TRIPS

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
# Check dataset
glimpse(odbus)
Rows: 5,721,503
Columns: 7
$ YEAR_MONTH          <chr> "2024-09", "2024-09", "2024-09", "2024-09", "2024-…
$ DAY_TYPE            <chr> "WEEKENDS/HOLIDAY", "WEEKENDS/HOLIDAY", "WEEKENDS/…
$ TIME_PER_HOUR       <dbl> 20, 19, 23, 14, 14, 18, 9, 15, 7, 21, 7, 7, 8, 10,…
$ PT_TYPE             <chr> "BUS", "BUS", "BUS", "BUS", "BUS", "BUS", "BUS", "…
$ ORIGIN_PT_CODE      <chr> "46009", "59091", "54181", "61039", "44629", "7720…
$ DESTINATION_PT_CODE <chr> "46249", "59419", "54201", "61111", "44009", "6441…
$ TOTAL_TRIPS         <dbl> 586, 54, 72, 256, 902, 6, 5, 15, 6, 4, 76, 36, 3, …

Since “ORIGIN_PT_CODE” and “DESTINATION_PT_CODE” is in string data type, I would need to convert them into factor data type.

# Convert to factor data type
odbus$ORIGIN_PT_CODE <- as.factor(odbus$ORIGIN_PT_CODE)
odbus$DESTINATION_PT_CODE <- as.factor(odbus$DESTINATION_PT_CODE) 

15.1.3 Aspatial Data Wrangling

The study data is focused on weekdays between 6-9 o’clock. Therefore, the dataset needs to be filtered accordingly.

# Filter odbus
odbus6_9 <- odbus %>%
  filter(DAY_TYPE == "WEEKDAY") %>%
  filter(TIME_PER_HOUR >= 6 &
           TIME_PER_HOUR <= 9) %>%
  group_by(ORIGIN_PT_CODE,
           DESTINATION_PT_CODE) %>%
  summarise(TRIPS = sum(TOTAL_TRIPS))
`summarise()` has grouped output by 'ORIGIN_PT_CODE'. You can override using
the `.groups` argument.

datatable() from DT package will be used to display the filtered dataset.

# Use datatable to show filtered data
datatable(odbus6_9)
Warning in instance$preRenderHook(instance): It seems your data is too big for
client-side DataTables. You may consider server-side processing:
https://rstudio.github.io/DT/server.html

I will save this in rds for easy retrieval.

# Save to rds
write_rds(odbus6_9, "data/processed/odbus6_9.rds")

This can also loaded back into R easiler

# Load odbus rds
odbus6_9 <- read_rds("data/processed/odbus6_9.rds")

15.1.4 Importing Geospatial Data

Using st_read() from sf package, I will load in to geospatial datasets - busstop and mpsz. I will also do projection for both with st_transform() .

# Load bus stop dataset
busstop <- st_read(dsn = "data/geospatial",
                   layer = "BusStop") %>%
  st_transform(crs = 3414)
Reading layer `BusStop' from data source 
  `C:\Users\Henry\Desktop\SMU Masters\2024-2025 T1\Geospatial Analytics & Applications\Project\GeospatialWebsite\Hands-On_Ex\Hands-On_Ex_10\data\geospatial' 
  using driver `ESRI Shapefile'
Simple feature collection with 5166 features and 3 fields
Geometry type: POINT
Dimension:     XY
Bounding box:  xmin: 3970.122 ymin: 26482.1 xmax: 48285.52 ymax: 52983.82
Projected CRS: SVY21
# Load mpsz dataset
mpsz <- st_read(dsn = "data/geospatial",
                   layer = "MPSZ-2019") %>%
  st_transform(crs = 3414)
Reading layer `MPSZ-2019' from data source 
  `C:\Users\Henry\Desktop\SMU Masters\2024-2025 T1\Geospatial Analytics & Applications\Project\GeospatialWebsite\Hands-On_Ex\Hands-On_Ex_10\data\geospatial' 
  using driver `ESRI Shapefile'
Simple feature collection with 332 features and 6 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: 103.6057 ymin: 1.158699 xmax: 104.0885 ymax: 1.470775
Geodetic CRS:  WGS 84

Now i will check the mpsz sf dataframe.

# Check mpsz
mpsz
Simple feature collection with 332 features and 6 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: 2667.538 ymin: 15748.72 xmax: 56396.44 ymax: 50256.33
Projected CRS: SVY21 / Singapore TM
First 10 features:
                 SUBZONE_N SUBZONE_C       PLN_AREA_N PLN_AREA_C       REGION_N
1              MARINA EAST    MESZ01      MARINA EAST         ME CENTRAL REGION
2         INSTITUTION HILL    RVSZ05     RIVER VALLEY         RV CENTRAL REGION
3           ROBERTSON QUAY    SRSZ01  SINGAPORE RIVER         SR CENTRAL REGION
4  JURONG ISLAND AND BUKOM    WISZ01  WESTERN ISLANDS         WI    WEST REGION
5             FORT CANNING    MUSZ02           MUSEUM         MU CENTRAL REGION
6         MARINA EAST (MP)    MPSZ05    MARINE PARADE         MP CENTRAL REGION
7                   SUDONG    WISZ03  WESTERN ISLANDS         WI    WEST REGION
8                  SEMAKAU    WISZ02  WESTERN ISLANDS         WI    WEST REGION
9           SOUTHERN GROUP    SISZ02 SOUTHERN ISLANDS         SI CENTRAL REGION
10                 SENTOSA    SISZ01 SOUTHERN ISLANDS         SI CENTRAL REGION
   REGION_C                       geometry
1        CR MULTIPOLYGON (((33222.98 29...
2        CR MULTIPOLYGON (((28481.45 30...
3        CR MULTIPOLYGON (((28087.34 30...
4        WR MULTIPOLYGON (((14557.7 304...
5        CR MULTIPOLYGON (((29542.53 31...
6        CR MULTIPOLYGON (((35279.55 30...
7        WR MULTIPOLYGON (((15772.59 21...
8        WR MULTIPOLYGON (((19843.41 21...
9        CR MULTIPOLYGON (((30870.53 22...
10       CR MULTIPOLYGON (((26879.04 26...

This will be saved to rds format for easy retrieval.

# Save to rds format
mpsz <- write_rds(mpsz, "data/processed/mpsz.rds")

15.1.5 Geospatial Data Wrangling

First, I will combine the busstop sf dataframe with the mpsz sf dataframe with st_intersection() from sf package. Next, only the relevant fields are selected. Finally, st_drop_geometry() will be used to remove the geometry column.

# Combine and process busstop_mpsz dataframe
busstop_mpsz <- st_intersection(busstop, mpsz) %>%
  select(BUS_STOP_N, SUBZONE_C) %>%
  st_drop_geometry()
Warning: attribute variables are assumed to be spatially constant throughout
all geometries
nrow(busstop) - nrow(busstop_mpsz)
[1] 5
Note

5 bus stops are excluded in the result as they are outside of Singapore boundary

datatable() from DT package is used to show the data

# Check result
datatable(busstop_mpsz)

I will save this as rds format for easy retrieval.

write_rds(busstop_mpsz, "data/processed/busstop_mpsz.rds")  

The planning subzone from busstop_mpsz dataframe can be appended to odbus6_9 with left_join(). The columns will also be renamed for consistency.

# Left join busstop_mpsz to odbus6_9 for origin pt code
od_data <- left_join(odbus6_9 , busstop_mpsz,
                     by = c("ORIGIN_PT_CODE" = "BUS_STOP_N")) %>%
  rename(ORIGIN_BS = ORIGIN_PT_CODE,
         ORIGIN_SZ = SUBZONE_C,
         DESTIN_BS = DESTINATION_PT_CODE)
Warning in left_join(odbus6_9, busstop_mpsz, by = c(ORIGIN_PT_CODE = "BUS_STOP_N")): Detected an unexpected many-to-many relationship between `x` and `y`.
ℹ Row 16245 of `x` matches multiple rows in `y`.
ℹ Row 674 of `y` matches multiple rows in `x`.
ℹ If a many-to-many relationship is expected, set `relationship =
  "many-to-many"` to silence this warning.
Note

Check for duplicates when doing left_join()

# Check for duplicates
duplicate <- od_data %>%
  group_by_all() %>%
  filter(n()>1) %>%
  ungroup()

Since there are duplicates, I need to retain the unique records.

# Get unique
od_data <- unique(od_data)

The earlier code chunk can be rerun to check that there are no further duplicates. Next, I will update the od_data with planning subzone codes for the destination bus stops.

# Left join busstop_mpsz to odbus6_9 for destination pt code
od_data <- left_join(od_data , busstop_mpsz,
            by = c("DESTIN_BS" = "BUS_STOP_N")) 
Warning in left_join(od_data, busstop_mpsz, by = c(DESTIN_BS = "BUS_STOP_N")): Detected an unexpected many-to-many relationship between `x` and `y`.
ℹ Row 162 of `x` matches multiple rows in `y`.
ℹ Row 673 of `y` matches multiple rows in `x`.
ℹ If a many-to-many relationship is expected, set `relationship =
  "many-to-many"` to silence this warning.

Again, I need to check for duplicates.

# Check for duplicates
duplicate <- od_data %>%
  group_by_all() %>%
  filter(n()>1) %>%
  ungroup()

Since there are duplicates, I will need to use unique() again.

# Get unique data
od_data <- unique(od_data)

Finally, I will do some minor processing tasks

  • Rename column
  • Remove na
  • Summarise number of trips by ORIGIN_SZ and DESTIN_SZ
# Process od_data
od_data <- od_data %>%
  rename(DESTIN_SZ = SUBZONE_C) %>%
  drop_na() %>%
  group_by(ORIGIN_SZ, DESTIN_SZ) %>%
  summarise(MORNING_PEAK = sum(TRIPS))
`summarise()` has grouped output by 'ORIGIN_SZ'. You can override using the
`.groups` argument.

With this, I can save the output into rds.

# Save to rds
write_rds(od_data, "data/processed/od_data_fii.rds")

# Read from rds
od_data_fii <- read_rds("data/processed/od_data_fii.rds")

15.2 Visualizing Spatial Interaction

15.2.1 Create Desire Line

Using stplanr package, I will prepare a desire line.

First, i need to remove intra-zonal flows. The output will be saved in rds.

# Remove intra-zonal flows
od_data_fij <- od_data[od_data$ORIGIN_SZ!=od_data$DESTIN_SZ,]

# Save output to rds
write_rds(od_data_fij, "data/processed/od_data_fij.rds")

# Read from rds
od_data_fij <- read_rds("data/processed/od_data_fij.rds")

od2line() from stplanr package will then be used to create the desire lines. This will also be saved into rds

# Create desire line
flowLine <- od2line(flow = od_data_fij, 
                    zones = mpsz,
                    zone_code = "SUBZONE_C")
Creating centroids representing desire line start and end points.
# Save output to rds
write_rds(flowLine, "data/processed/flowLine.rds")

# Read from rds
flowLine <- read_rds("data/processed/flowLine.rds")

15.2.2 Visualize Desire Lines

tmap package will be used to visualize the desire lines.

# Visualize desire lines
tm_shape(mpsz) +
  tm_polygons() +
flowLine %>%  
tm_shape() +
  tm_lines(lwd = "MORNING_PEAK",
           style = "quantile",
           scale = c(0.1, 1, 3, 5, 7, 10),
           n = 6,
           alpha = 0.3)
Warning in g$scale * (w_legend/maxW): longer object length is not a multiple of
shorter object length

Since the flow data is very messy, I should focus on selected flows (i.e. those greater than or equal to 5000).

# Updated visualization of desire lines
tm_shape(mpsz) +
  tm_polygons() +
flowLine %>%  
  filter(MORNING_PEAK >= 5000) %>%
tm_shape() +
  tm_lines(lwd = "MORNING_PEAK",
           style = "quantile",
           scale = c(0.1, 1, 3, 5, 7, 10),
           n = 6,
           alpha = 0.3)
Warning in g$scale * (w_legend/maxW): longer object length is not a multiple of
shorter object length
Warning in g$scale * (x/maxW): longer object length is not a multiple of
shorter object length

Chapter 16: Calibrating Spatial Interaction Models with R

16.1 Setting Up

Spatial Interaction Models (SIMs) are mathematical models for estimating flows between spatial entities developed by Alan Wilson in the late 1960s and early 1970, with considerable uptake and refinement for transport modelling since then Boyce and Williams (2015).

Note

There are four main types of traditional SIMs (Wilson 1971):

  • Unconstrained
  • Production-constrained
  • Attraction-constrained
  • Doubly-constrained

The objective of this section is to calibrate SIM to determine factors affecting the public bus passenger flows during the morning peak in Singapore

16.2 Compute Distance Matrix

First, I’ll load in the mpsz sf dataframe again.

# Load mpsz
mpsz <- read_rds("data/processed/mpsz.rds")

# Check sf dataframe
mpsz
Simple feature collection with 332 features and 6 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: 2667.538 ymin: 15748.72 xmax: 56396.44 ymax: 50256.33
Projected CRS: SVY21 / Singapore TM
First 10 features:
                 SUBZONE_N SUBZONE_C       PLN_AREA_N PLN_AREA_C       REGION_N
1              MARINA EAST    MESZ01      MARINA EAST         ME CENTRAL REGION
2         INSTITUTION HILL    RVSZ05     RIVER VALLEY         RV CENTRAL REGION
3           ROBERTSON QUAY    SRSZ01  SINGAPORE RIVER         SR CENTRAL REGION
4  JURONG ISLAND AND BUKOM    WISZ01  WESTERN ISLANDS         WI    WEST REGION
5             FORT CANNING    MUSZ02           MUSEUM         MU CENTRAL REGION
6         MARINA EAST (MP)    MPSZ05    MARINE PARADE         MP CENTRAL REGION
7                   SUDONG    WISZ03  WESTERN ISLANDS         WI    WEST REGION
8                  SEMAKAU    WISZ02  WESTERN ISLANDS         WI    WEST REGION
9           SOUTHERN GROUP    SISZ02 SOUTHERN ISLANDS         SI CENTRAL REGION
10                 SENTOSA    SISZ01 SOUTHERN ISLANDS         SI CENTRAL REGION
   REGION_C                       geometry
1        CR MULTIPOLYGON (((33222.98 29...
2        CR MULTIPOLYGON (((28481.45 30...
3        CR MULTIPOLYGON (((28087.34 30...
4        WR MULTIPOLYGON (((14557.7 304...
5        CR MULTIPOLYGON (((29542.53 31...
6        CR MULTIPOLYGON (((35279.55 30...
7        WR MULTIPOLYGON (((15772.59 21...
8        WR MULTIPOLYGON (((19843.41 21...
9        CR MULTIPOLYGON (((30870.53 22...
10       CR MULTIPOLYGON (((26879.04 26...

To compute the distance matrix, I need to first convert the sf dataframe into a SpatialPolygonsDataFrame with as.Spatial().

# Convert into spatialpolygonsdataframe
mpsz_sp <- as_Spatial(mpsz)

# Check output
mpsz_sp
class       : SpatialPolygonsDataFrame 
features    : 332 
extent      : 2667.538, 56396.44, 15748.72, 50256.33  (xmin, xmax, ymin, ymax)
crs         : +proj=tmerc +lat_0=1.36666666666667 +lon_0=103.833333333333 +k=1 +x_0=28001.642 +y_0=38744.572 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs 
variables   : 6
names       : SUBZONE_N, SUBZONE_C, PLN_AREA_N, PLN_AREA_C,       REGION_N, REGION_C 
min values  : ADMIRALTY,    AMSZ01, ANG MO KIO,         AM, CENTRAL REGION,       CR 
max values  :    YUNNAN,    YSSZ09,     YISHUN,         YS,    WEST REGION,       WR 

Now, i can compute the distance matrix with spDists()

# Compute distance matrix
dist <- spDists(mpsz_sp, 
                longlat = FALSE)

# Check distance matrix
head(dist, n=c(10, 10))
           [,1]       [,2]      [,3]      [,4]       [,5]      [,6]      [,7]
 [1,]     0.000  3926.0025  3939.108 20252.964  2989.9839  1431.330 19211.836
 [2,]  3926.003     0.0000   305.737 16513.865   951.8314  5254.066 16242.523
 [3,]  3939.108   305.7370     0.000 16412.062  1045.9088  5299.849 16026.146
 [4,] 20252.964 16513.8648 16412.062     0.000 17450.3044 21665.795  7229.017
 [5,]  2989.984   951.8314  1045.909 17450.304     0.0000  4303.232 17020.916
 [6,]  1431.330  5254.0664  5299.849 21665.795  4303.2323     0.000 20617.082
 [7,] 19211.836 16242.5230 16026.146  7229.017 17020.9161 20617.082     0.000
 [8,] 14960.942 12749.4101 12477.871 11284.279 13336.0421 16281.453  5606.082
 [9,]  7515.256  7934.8082  7649.776 18427.503  7801.6163  8403.896 14810.930
[10,]  6391.342  4975.0021  4669.295 15469.566  5226.8731  7707.091 13111.391
           [,8]      [,9]     [,10]
 [1,] 14960.942  7515.256  6391.342
 [2,] 12749.410  7934.808  4975.002
 [3,] 12477.871  7649.776  4669.295
 [4,] 11284.279 18427.503 15469.566
 [5,] 13336.042  7801.616  5226.873
 [6,] 16281.453  8403.896  7707.091
 [7,]  5606.082 14810.930 13111.391
 [8,]     0.000  9472.024  8575.490
 [9,]  9472.024     0.000  3780.800
[10,]  8575.490  3780.800     0.000

Additional processing steps are be done:

  1. Label column and row headers
  2. Pivot from wide to long format
  3. Update intra-zonal distances
  4. Rename origin and destination fields
# Prepare subzone codes
sz_names <- mpsz$SUBZONE_C

# Attach subzone codes to row and column
colnames(dist) <- paste0(sz_names)
rownames(dist) <- paste0(sz_names)
# Pivot from wide to long
distPair <- melt(dist) %>%
  rename(dist = value)

# Check output
head(distPair, 10)
     Var1   Var2      dist
1  MESZ01 MESZ01     0.000
2  RVSZ05 MESZ01  3926.003
3  SRSZ01 MESZ01  3939.108
4  WISZ01 MESZ01 20252.964
5  MUSZ02 MESZ01  2989.984
6  MPSZ05 MESZ01  1431.330
7  WISZ03 MESZ01 19211.836
8  WISZ02 MESZ01 14960.942
9  SISZ02 MESZ01  7515.256
10 SISZ01 MESZ01  6391.342

A constant value will be used to replace the intra-zonal distance that are 0. For that, I will uset he minimum distance. sumamry() will be used to find out what that value is.

# Check the minimum value of distance 
distPair %>%
  filter(dist > 0) %>%
  summary()
      Var1             Var2             dist        
 MESZ01 :   331   MESZ01 :   331   Min.   :  173.8  
 RVSZ05 :   331   RVSZ05 :   331   1st Qu.: 7149.5  
 SRSZ01 :   331   SRSZ01 :   331   Median :11890.0  
 WISZ01 :   331   WISZ01 :   331   Mean   :12229.4  
 MUSZ02 :   331   MUSZ02 :   331   3rd Qu.:16401.7  
 MPSZ05 :   331   MPSZ05 :   331   Max.   :49894.4  
 (Other):107906   (Other):107906                    

I’ll use a distance of 174m to the intra-zonal distance.

# Update distance pair
distPair$dist <- ifelse(distPair$dist == 0,
                        174, distPair$dist)

# Check result
summary(distPair)
      Var1             Var2             dist        
 MESZ01 :   332   MESZ01 :   332   Min.   :  173.8  
 RVSZ05 :   332   RVSZ05 :   332   1st Qu.: 7097.3  
 SRSZ01 :   332   SRSZ01 :   332   Median :11863.7  
 WISZ01 :   332   WISZ01 :   332   Mean   :12193.1  
 MUSZ02 :   332   MUSZ02 :   332   3rd Qu.:16387.7  
 MPSZ05 :   332   MPSZ05 :   332   Max.   :49894.4  
 (Other):108232   (Other):108232                    

The final step is then to rename the columns into orig and dest.

# Rename columns
distPair <- distPair %>%
  rename(orig = Var1,
         dest = Var2)

The result will be saved as rds

# Save output to rds
write_rds(distPair, "data/processed/distPair.rds") 

# Read distPair from rds
distPair <- read_rds("data/processed/distPair.rds")

16.3 Preparing Spatial Interaction Model (SIM) Data

In this section, I will prepare the SIM data for 16.4.

16.3.1 Preparing Flow Data

A few steps are required to prepare the flow data:

  1. Compute flow data (total passenger trip between and within planning subzones)
  2. Create additional flow attributes
  3. Combine passenger volume data with distance value

I’ll first load in the od_data created in 15.1.5.

# Load od_data_fii
od_data_fii <- read_rds("data/processed/od_data_fii.rds")

To get the flow data, passenger trips (MORNING_PEAK) will be summed by ORIGIN_SZ (from) and DESTIN_SZ (to). Once done, I will check the flow_data dataframe.

flow_data <- od_data_fii %>%
  group_by(ORIGIN_SZ, DESTIN_SZ) %>% 
  summarize(TRIPS = sum(MORNING_PEAK)) 
`summarise()` has grouped output by 'ORIGIN_SZ'. You can override using the
`.groups` argument.
# Check output
head(flow_data, 10)
# A tibble: 10 × 3
# Groups:   ORIGIN_SZ [1]
   ORIGIN_SZ DESTIN_SZ TRIPS
   <chr>     <chr>     <dbl>
 1 AMSZ01    AMSZ01     2421
 2 AMSZ01    AMSZ02    10201
 3 AMSZ01    AMSZ03    14675
 4 AMSZ01    AMSZ04     2892
 5 AMSZ01    AMSZ05     7686
 6 AMSZ01    AMSZ06     2374
 7 AMSZ01    AMSZ07     1325
 8 AMSZ01    AMSZ08     2593
 9 AMSZ01    AMSZ09     2296
10 AMSZ01    AMSZ10      257

Additional attributes will be created

  • FlowNoIntra - remove all intra-region trips, coding them as 0 instead
  • offset - set weights of intra-region trips to be very low (0.000001), and inter-region trips to be 1
# Create additional attributes
flow_data$FlowNoIntra <- ifelse(
  flow_data$ORIGIN_SZ == flow_data$DESTIN_SZ, 
  0, flow_data$TRIPS)
flow_data$offset <- ifelse(
  flow_data$ORIGIN_SZ == flow_data$DESTIN_SZ, 
  0.000001, 1)

Before joining the passenger volume data with distance pair, I need to convert the ORIGIN_SZ and DESTIN_SZ fields into factor data type. left_join will then be used to merge the 2 dataframes.

# Convert to factor data type
flow_data$ORIGIN_SZ <- as.factor(flow_data$ORIGIN_SZ)
flow_data$DESTIN_SZ <- as.factor(flow_data$DESTIN_SZ)

# Join passenger volume dataframe to distance pair dataframe
flow_data1 <- flow_data %>%
  left_join (distPair,
             by = c("ORIGIN_SZ" = "orig",
                    "DESTIN_SZ" = "dest"))

16.3.2 Preparing Origin and Destination Attributes

In this section, I will do further data processing to add demographics data. First, the population dataset will be read with read_csv() from readr package.

# Load population dataset
pop <- read_csv("data/aspatial/pop.csv")
Rows: 332 Columns: 5
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (2): PA, SZ
dbl (3): AGE7_12, AGE13_24, AGE25_64

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

Next, I will merge the population dataset with the mpsz sf dataframe to get population by subzone. The columns are renamed for better readability.

# Join population dataset with mpsz sf dataframe
pop <- pop %>%
  left_join(mpsz,
            by = c("PA" = "PLN_AREA_N",
                   "SZ" = "SUBZONE_N")) %>%
  select(1:6) %>%
  rename(SZ_NAME = SZ,
         SZ = SUBZONE_C)

Now, I will add the population data to the processed flow_data for both the origin (ORIGIN_SZ) and destination (DESTIN_SZ). The column names from population will be renamed to distinguish between origin and destination.

# Join population data to flow data on origin
flow_data1 <- flow_data1 %>%
  left_join(pop,
            by = c(ORIGIN_SZ = "SZ")) %>%
  rename(ORIGIN_AGE7_12 = AGE7_12,
         ORIGIN_AGE13_24 = AGE13_24,
         ORIGIN_AGE25_64 = AGE25_64) %>%
  select(-c(PA, SZ_NAME))

# Join population data to flow data on destination
flow_data1 <- flow_data1 %>%
  left_join(pop,
            by = c(DESTIN_SZ = "SZ")) %>%
  rename(DESTIN_AGE7_12 = AGE7_12,
         DESTIN_AGE13_24 = AGE13_24,
         DESTIN_AGE25_64 = AGE25_64) %>%
  select(-c(PA, SZ_NAME))

Finally, this will be saved as rds format.

write_rds(flow_data1, "data/processed/SIM_data.rds")

16.4 Calibrating Spatial Interaction Model

Lets load in the modelling data from 16.3.2.

# Load SIM data
SIM_data <- read_rds("data/processed/SIM_data.rds")

16.4.1 Exploratory Data Analysis

It is always good to have a quick look at the data. I can view the distribution of the dependent variable (TRIPS) with a histogram.

# Visualize distribution of TRIPS
ggplot(data = SIM_data,
       aes(x = TRIPS)) +
  geom_histogram()
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

The distribution seems to be highly skewed and does not resemble a normal distribution. Next, I will visualize the relationship between the dependent variable and a key independent variable (distance).

# Visualize TRIPS vs dist
ggplot(data = SIM_data,
       aes(x = dist,
           y = TRIPS)) +
  geom_point() +
  geom_smooth(method = lm)
`geom_smooth()` using formula = 'y ~ x'

This relationship does not seem to resemble a linear relationship. However, if I were to use a log transformed version of both variables, it seems that they share a linear relationship.

# Visualize log TRIPS vs log distance
ggplot(data = SIM_data,
       aes(x = log(dist),
           y = log(TRIPS))) +
  geom_point() +
  geom_smooth(method = lm)
`geom_smooth()` using formula = 'y ~ x'

Given that Poisson Regression is based on log, I need to make sure that there are no 0 values (log(0) is undefined) in the independent variables. I can do that by checking the data with summary()

# Check SIM data distribution
summary(SIM_data)
  ORIGIN_SZ          DESTIN_SZ             TRIPS         FlowNoIntra      
 Length:21189       Length:21189       Min.   :     1   Min.   :     0.0  
 Class :character   Class :character   1st Qu.:    16   1st Qu.:    14.0  
 Mode  :character   Mode  :character   Median :    84   Median :    77.0  
                                       Mean   :  1113   Mean   :   926.5  
                                       3rd Qu.:   435   3rd Qu.:   400.0  
                                       Max.   :326696   Max.   :201325.0  
     offset              dist         ORIGIN_AGE7_12   ORIGIN_AGE13_24
 Min.   :0.000001   Min.   :  173.8   Min.   :   0.0   Min.   :    0  
 1st Qu.:1.000000   1st Qu.: 3377.2   1st Qu.:  50.0   1st Qu.:  100  
 Median :1.000000   Median : 6181.2   Median : 510.0   Median : 1130  
 Mean   :0.986267   Mean   : 7021.9   Mean   : 885.8   Mean   : 1948  
 3rd Qu.:1.000000   3rd Qu.: 9967.3   3rd Qu.:1360.0   3rd Qu.: 2950  
 Max.   :1.000000   Max.   :26135.8   Max.   :6340.0   Max.   :16380  
 ORIGIN_AGE25_64 DESTIN_AGE7_12   DESTIN_AGE13_24 DESTIN_AGE25_64
 Min.   :    0   Min.   :   0.0   Min.   :    0   Min.   :    0  
 1st Qu.:  730   1st Qu.:  10.0   1st Qu.:   60   1st Qu.:  630  
 Median : 5710   Median : 510.0   Median : 1090   Median : 5640  
 Mean   : 9064   Mean   : 847.4   Mean   : 1880   Mean   : 8760  
 3rd Qu.:14180   3rd Qu.:1200.0   3rd Qu.: 2920   3rd Qu.:13650  
 Max.   :74610   Max.   :6340.0   Max.   :16380   Max.   :74610  

From the summary report, ORIGIN_AGE7_12, ORIGIN_AGE13_24, ORIGIN_AGE25_64,DESTIN_AGE7_12, DESTIN_AGE13_24, DESTIN_AGE25_64 contains 0 values. Therefore, I will need to replace them with a small value (0.99). After that, summary() will be used to check the data again.

# Replace 0 value with 0.99
SIM_data$DESTIN_AGE7_12 <- ifelse(
  SIM_data$DESTIN_AGE7_12 == 0,
  0.99, SIM_data$DESTIN_AGE7_12)
SIM_data$DESTIN_AGE13_24 <- ifelse(
  SIM_data$DESTIN_AGE13_24 == 0,
  0.99, SIM_data$DESTIN_AGE13_24)
SIM_data$DESTIN_AGE25_64 <- ifelse(
  SIM_data$DESTIN_AGE25_64 == 0,
  0.99, SIM_data$DESTIN_AGE25_64)
SIM_data$ORIGIN_AGE7_12 <- ifelse(
  SIM_data$ORIGIN_AGE7_12 == 0,
  0.99, SIM_data$ORIGIN_AGE7_12)
SIM_data$ORIGIN_AGE13_24 <- ifelse(
  SIM_data$ORIGIN_AGE13_24 == 0,
  0.99, SIM_data$ORIGIN_AGE13_24)
SIM_data$ORIGIN_AGE25_64 <- ifelse(
  SIM_data$ORIGIN_AGE25_64 == 0,
  0.99, SIM_data$ORIGIN_AGE25_64)

# Check result
summary(SIM_data)
  ORIGIN_SZ          DESTIN_SZ             TRIPS         FlowNoIntra      
 Length:21189       Length:21189       Min.   :     1   Min.   :     0.0  
 Class :character   Class :character   1st Qu.:    16   1st Qu.:    14.0  
 Mode  :character   Mode  :character   Median :    84   Median :    77.0  
                                       Mean   :  1113   Mean   :   926.5  
                                       3rd Qu.:   435   3rd Qu.:   400.0  
                                       Max.   :326696   Max.   :201325.0  
     offset              dist         ORIGIN_AGE7_12    ORIGIN_AGE13_24   
 Min.   :0.000001   Min.   :  173.8   Min.   :   0.99   Min.   :    0.99  
 1st Qu.:1.000000   1st Qu.: 3377.2   1st Qu.:  50.00   1st Qu.:  100.00  
 Median :1.000000   Median : 6181.2   Median : 510.00   Median : 1130.00  
 Mean   :0.986267   Mean   : 7021.9   Mean   : 885.97   Mean   : 1948.18  
 3rd Qu.:1.000000   3rd Qu.: 9967.3   3rd Qu.:1360.00   3rd Qu.: 2950.00  
 Max.   :1.000000   Max.   :26135.8   Max.   :6340.00   Max.   :16380.00  
 ORIGIN_AGE25_64    DESTIN_AGE7_12    DESTIN_AGE13_24    DESTIN_AGE25_64   
 Min.   :    0.99   Min.   :   0.99   Min.   :    0.99   Min.   :    0.99  
 1st Qu.:  730.00   1st Qu.:  10.00   1st Qu.:   60.00   1st Qu.:  630.00  
 Median : 5710.00   Median : 510.00   Median : 1090.00   Median : 5640.00  
 Mean   : 9064.37   Mean   : 847.64   Mean   : 1880.59   Mean   : 8760.31  
 3rd Qu.:14180.00   3rd Qu.:1200.00   3rd Qu.: 2920.00   3rd Qu.:13650.00  
 Max.   :74610.00   Max.   :6340.00   Max.   :16380.00   Max.   :74610.00  

16.4.2 Unconstrained Spatial Interaction Model

Using glm() from base stats, I will calibrate an unconstrained spatial interaction model (SIM). The explanatory/independent variables used are origin population and destination population by different age cohort, and distance between origin and destination (in kilometre).

The general formula of the unconstrained SIM is as follows:

\[ \lambda_{ij} = \exp(k + \mu \ln V_i + \alpha \ln W_j - \beta \ln d_{ij}) \]

# Calibrate unconstrained SIM
uncSIM <- glm(formula = TRIPS ~ 
                log(ORIGIN_AGE25_64) + 
                log(DESTIN_AGE25_64) +
                log(dist),
              family = poisson(link = "log"),
              data = SIM_data,
              na.action = na.exclude)

# Check output
uncSIM

Call:  glm(formula = TRIPS ~ log(ORIGIN_AGE25_64) + log(DESTIN_AGE25_64) + 
    log(dist), family = poisson(link = "log"), data = SIM_data, 
    na.action = na.exclude)

Coefficients:
         (Intercept)  log(ORIGIN_AGE25_64)  log(DESTIN_AGE25_64)  
            12.77060               0.27579               0.02557  
           log(dist)  
            -1.01728  

Degrees of Freedom: 21188 Total (i.e. Null);  21185 Residual
Null Deviance:      100300000 
Residual Deviance: 54440000     AIC: 54570000

I will also create a R-square function to check how much variation of the trips the model can account for.

# Custom R square function 
CalcRSquared <- function(observed,estimated){
  r <- cor(observed,estimated)
  R2 <- r^2
  R2
}

Now, I will compute the R-square of the unconstrained SIM and compare it with the R-square of a generalized linear regression (using r2_macfadden() from performance package).

# Compute R square of unconstrained SIM
CalcRSquared(uncSIM$data$TRIPS, uncSIM$fitted.values)
[1] 0.2192494
# Compute R square of generalized linear regression
r2_mcfadden(uncSIM)
# R2 for Generalized Linear Regression
       R2: 0.457
  adj. R2: 0.457

Looks like the unconstrained SIM performs worse than a generalized linear regression model.

16.4.3 Origin (Production) constrained SIM

Using glm(), I will calibrate an origin constrained spatial interaction model (SIM). This is done by adding in origin (ORIGIN_SZ) as a independent variable.

The general formula of the origin constrained SIM is as follows:

\[ \lambda_{ij} = \exp(k + \mu_i + \alpha \ln W_j - \beta \ln d_{ij}) \]

# Calibrate origin constrained SIM
orcSIM <- glm(formula = TRIPS ~ 
                 ORIGIN_SZ +
                 log(DESTIN_AGE25_64) +
                 log(dist),
              family = poisson(link = "log"),
              data = SIM_data,
              na.action = na.exclude)

# Check output
summary(orcSIM)

Call:
glm(formula = TRIPS ~ ORIGIN_SZ + log(DESTIN_AGE25_64) + log(dist), 
    family = poisson(link = "log"), data = SIM_data, na.action = na.exclude)

Coefficients:
                       Estimate Std. Error   z value Pr(>|z|)    
(Intercept)           1.492e+01  3.308e-03  4508.112  < 2e-16 ***
ORIGIN_SZAMSZ02       9.973e-01  3.754e-03   265.667  < 2e-16 ***
ORIGIN_SZAMSZ03       6.095e-01  3.855e-03   158.102  < 2e-16 ***
ORIGIN_SZAMSZ04      -1.479e-03  4.364e-03    -0.339   0.7346    
ORIGIN_SZAMSZ05      -1.896e-01  4.962e-03   -38.204  < 2e-16 ***
ORIGIN_SZAMSZ06       2.535e-01  4.482e-03    56.563  < 2e-16 ***
ORIGIN_SZAMSZ07      -1.133e+00  7.512e-03  -150.839  < 2e-16 ***
ORIGIN_SZAMSZ08      -8.104e-01  6.962e-03  -116.410  < 2e-16 ***
ORIGIN_SZAMSZ09       1.979e-01  4.617e-03    42.854  < 2e-16 ***
ORIGIN_SZAMSZ10       2.985e-01  4.251e-03    70.202  < 2e-16 ***
ORIGIN_SZAMSZ11      -1.370e+00  9.049e-03  -151.457  < 2e-16 ***
ORIGIN_SZAMSZ12      -1.558e+00  9.141e-03  -170.447  < 2e-16 ***
ORIGIN_SZBDSZ01       1.062e+00  3.729e-03   284.757  < 2e-16 ***
ORIGIN_SZBDSZ02       5.645e-01  4.293e-03   131.495  < 2e-16 ***
ORIGIN_SZBDSZ03       1.054e+00  3.812e-03   276.472  < 2e-16 ***
ORIGIN_SZBDSZ04       1.846e+00  3.337e-03   553.109  < 2e-16 ***
ORIGIN_SZBDSZ05       8.597e-01  3.788e-03   226.938  < 2e-16 ***
ORIGIN_SZBDSZ06       1.056e+00  3.829e-03   275.866  < 2e-16 ***
ORIGIN_SZBDSZ07      -8.060e-01  6.931e-03  -116.292  < 2e-16 ***
ORIGIN_SZBDSZ08      -7.434e-01  6.826e-03  -108.907  < 2e-16 ***
ORIGIN_SZBKSZ01      -3.244e-01  5.384e-03   -60.254  < 2e-16 ***
ORIGIN_SZBKSZ02       3.997e-01  4.324e-03    92.443  < 2e-16 ***
ORIGIN_SZBKSZ03       7.654e-01  4.008e-03   190.949  < 2e-16 ***
ORIGIN_SZBKSZ04      -1.974e-02  4.898e-03    -4.031 5.56e-05 ***
ORIGIN_SZBKSZ05       1.045e-01  4.586e-03    22.788  < 2e-16 ***
ORIGIN_SZBKSZ06       1.935e-02  4.929e-03     3.925 8.66e-05 ***
ORIGIN_SZBKSZ07       8.179e-01  3.723e-03   219.686  < 2e-16 ***
ORIGIN_SZBKSZ08       1.259e-01  4.406e-03    28.585  < 2e-16 ***
ORIGIN_SZBKSZ09       6.519e-02  4.622e-03    14.103  < 2e-16 ***
ORIGIN_SZBLSZ01      -1.469e+00  1.079e-02  -136.119  < 2e-16 ***
ORIGIN_SZBLSZ02      -2.171e+00  1.593e-02  -136.301  < 2e-16 ***
ORIGIN_SZBLSZ03      -3.183e+00  3.190e-02   -99.765  < 2e-16 ***
ORIGIN_SZBLSZ04      -1.702e+00  1.494e-02  -113.956  < 2e-16 ***
ORIGIN_SZBMSZ01       2.872e-01  4.011e-03    71.587  < 2e-16 ***
ORIGIN_SZBMSZ02      -1.199e+00  5.744e-03  -208.707  < 2e-16 ***
ORIGIN_SZBMSZ03      -3.828e-01  4.629e-03   -82.698  < 2e-16 ***
ORIGIN_SZBMSZ04      -1.266e-01  4.096e-03   -30.901  < 2e-16 ***
ORIGIN_SZBMSZ05      -1.378e+00  6.237e-03  -220.885  < 2e-16 ***
ORIGIN_SZBMSZ06      -1.872e+00  9.522e-03  -196.582  < 2e-16 ***
ORIGIN_SZBMSZ07      -3.887e-01  4.546e-03   -85.502  < 2e-16 ***
ORIGIN_SZBMSZ08      -5.320e-01  4.596e-03  -115.759  < 2e-16 ***
ORIGIN_SZBMSZ09      -1.226e+00  5.876e-03  -208.654  < 2e-16 ***
ORIGIN_SZBMSZ10      -1.310e+00  6.268e-03  -209.079  < 2e-16 ***
ORIGIN_SZBMSZ11      -9.506e-01  5.461e-03  -174.077  < 2e-16 ***
ORIGIN_SZBMSZ12      -1.074e+00  6.895e-03  -155.712  < 2e-16 ***
ORIGIN_SZBMSZ13      -5.004e-02  4.515e-03   -11.084  < 2e-16 ***
ORIGIN_SZBMSZ14      -6.662e-01  5.376e-03  -123.922  < 2e-16 ***
ORIGIN_SZBMSZ15      -3.991e-01  4.869e-03   -81.984  < 2e-16 ***
ORIGIN_SZBMSZ16      -1.314e+00  6.172e-03  -212.846  < 2e-16 ***
ORIGIN_SZBMSZ17      -1.788e+00  9.456e-03  -189.063  < 2e-16 ***
ORIGIN_SZBPSZ01       2.174e-01  4.637e-03    46.888  < 2e-16 ***
ORIGIN_SZBPSZ02       1.113e-01  5.117e-03    21.755  < 2e-16 ***
ORIGIN_SZBPSZ03       3.970e-01  4.735e-03    83.837  < 2e-16 ***
ORIGIN_SZBPSZ04       5.318e-01  4.175e-03   127.377  < 2e-16 ***
ORIGIN_SZBPSZ05       6.193e-01  3.858e-03   160.529  < 2e-16 ***
ORIGIN_SZBPSZ06      -9.138e-01  6.708e-03  -136.222  < 2e-16 ***
ORIGIN_SZBPSZ07      -7.265e-01  6.617e-03  -109.789  < 2e-16 ***
ORIGIN_SZBSSZ01       4.647e-02  4.465e-03    10.408  < 2e-16 ***
ORIGIN_SZBSSZ02       4.311e-01  4.017e-03   107.327  < 2e-16 ***
ORIGIN_SZBSSZ03       2.857e-01  3.981e-03    71.755  < 2e-16 ***
ORIGIN_SZBTSZ01       1.890e-01  4.304e-03    43.908  < 2e-16 ***
ORIGIN_SZBTSZ02      -8.828e-01  6.292e-03  -140.318  < 2e-16 ***
ORIGIN_SZBTSZ03       3.561e-03  4.600e-03     0.774   0.4388    
ORIGIN_SZBTSZ04      -7.815e-01  7.513e-03  -104.021  < 2e-16 ***
ORIGIN_SZBTSZ05      -1.417e+00  8.631e-03  -164.200  < 2e-16 ***
ORIGIN_SZBTSZ06      -6.798e-01  5.862e-03  -115.982  < 2e-16 ***
ORIGIN_SZBTSZ07      -1.763e+00  8.554e-03  -206.102  < 2e-16 ***
ORIGIN_SZBTSZ08      -1.063e+00  6.909e-03  -153.880  < 2e-16 ***
ORIGIN_SZCCSZ01      -1.489e+00  1.079e-02  -137.921  < 2e-16 ***
ORIGIN_SZCHSZ01      -1.026e+00  9.336e-03  -109.929  < 2e-16 ***
ORIGIN_SZCHSZ02      -6.286e-01  6.890e-03   -91.241  < 2e-16 ***
ORIGIN_SZCHSZ03       8.083e-01  4.663e-03   173.322  < 2e-16 ***
ORIGIN_SZCKSZ01       4.126e-01  4.147e-03    99.496  < 2e-16 ***
ORIGIN_SZCKSZ02       8.279e-01  4.160e-03   199.000  < 2e-16 ***
ORIGIN_SZCKSZ03       9.117e-01  3.803e-03   239.724  < 2e-16 ***
ORIGIN_SZCKSZ04       1.309e+00  3.867e-03   338.436  < 2e-16 ***
ORIGIN_SZCKSZ05       9.915e-01  4.463e-03   222.141  < 2e-16 ***
ORIGIN_SZCKSZ06       1.220e+00  4.268e-03   285.788  < 2e-16 ***
ORIGIN_SZCLSZ01      -3.506e-01  5.718e-03   -61.305  < 2e-16 ***
ORIGIN_SZCLSZ02      -1.651e+00  1.086e-02  -151.973  < 2e-16 ***
ORIGIN_SZCLSZ03      -3.703e-01  5.399e-03   -68.588  < 2e-16 ***
ORIGIN_SZCLSZ04       8.543e-01  3.727e-03   229.221  < 2e-16 ***
ORIGIN_SZCLSZ05      -1.667e+00  1.021e-02  -163.290  < 2e-16 ***
ORIGIN_SZCLSZ06       9.505e-01  3.558e-03   267.117  < 2e-16 ***
ORIGIN_SZCLSZ07      -7.409e-02  4.482e-03   -16.533  < 2e-16 ***
ORIGIN_SZCLSZ08       2.681e-01  4.917e-03    54.522  < 2e-16 ***
ORIGIN_SZCLSZ09      -1.604e+00  1.286e-02  -124.717  < 2e-16 ***
ORIGIN_SZDTSZ01      -1.867e+00  7.108e-03  -262.653  < 2e-16 ***
ORIGIN_SZDTSZ02      -1.725e+00  6.715e-03  -256.852  < 2e-16 ***
ORIGIN_SZDTSZ03      -3.100e+00  1.494e-02  -207.430  < 2e-16 ***
ORIGIN_SZDTSZ04      -4.545e+00  8.310e-02   -54.696  < 2e-16 ***
ORIGIN_SZDTSZ05      -3.438e+00  2.432e-02  -141.346  < 2e-16 ***
ORIGIN_SZDTSZ06      -3.224e+00  1.939e-02  -166.261  < 2e-16 ***
ORIGIN_SZDTSZ07      -2.240e+00  1.887e-02  -118.691  < 2e-16 ***
ORIGIN_SZDTSZ08      -2.377e+00  9.756e-03  -243.607  < 2e-16 ***
ORIGIN_SZDTSZ09      -3.293e+00  2.087e-02  -157.761  < 2e-16 ***
ORIGIN_SZDTSZ10      -2.281e+00  1.045e-02  -218.334  < 2e-16 ***
ORIGIN_SZDTSZ11      -2.377e+00  1.080e-02  -220.167  < 2e-16 ***
ORIGIN_SZDTSZ12      -3.703e+00  2.700e-02  -137.178  < 2e-16 ***
ORIGIN_SZDTSZ13      -2.458e+00  1.257e-02  -195.471  < 2e-16 ***
ORIGIN_SZGLSZ01      -1.350e+00  7.255e-03  -186.026  < 2e-16 ***
ORIGIN_SZGLSZ02       2.456e-01  4.149e-03    59.204  < 2e-16 ***
ORIGIN_SZGLSZ03       2.787e-01  4.127e-03    67.531  < 2e-16 ***
ORIGIN_SZGLSZ04       1.064e+00  3.478e-03   306.057  < 2e-16 ***
ORIGIN_SZGLSZ05       7.601e-01  3.694e-03   205.738  < 2e-16 ***
ORIGIN_SZHGSZ01       2.609e-01  4.093e-03    63.736  < 2e-16 ***
ORIGIN_SZHGSZ02       6.033e-01  3.921e-03   153.867  < 2e-16 ***
ORIGIN_SZHGSZ03       2.773e-01  4.310e-03    64.337  < 2e-16 ***
ORIGIN_SZHGSZ04       9.544e-01  3.661e-03   260.666  < 2e-16 ***
ORIGIN_SZHGSZ05       1.251e+00  3.601e-03   347.435  < 2e-16 ***
ORIGIN_SZHGSZ06       1.289e-01  4.345e-03    29.662  < 2e-16 ***
ORIGIN_SZHGSZ07       7.406e-01  3.784e-03   195.739  < 2e-16 ***
ORIGIN_SZHGSZ08       2.502e-01  4.341e-03    57.625  < 2e-16 ***
ORIGIN_SZHGSZ09      -6.254e-01  5.876e-03  -106.429  < 2e-16 ***
ORIGIN_SZHGSZ10      -3.738e+00  3.856e-02   -96.960  < 2e-16 ***
ORIGIN_SZJESZ01       4.212e-01  4.162e-03   101.204  < 2e-16 ***
ORIGIN_SZJESZ02       2.463e-01  4.196e-03    58.715  < 2e-16 ***
ORIGIN_SZJESZ03       2.159e-01  4.419e-03    48.843  < 2e-16 ***
ORIGIN_SZJESZ04      -9.247e-01  6.955e-03  -132.955  < 2e-16 ***
ORIGIN_SZJESZ05      -2.094e+00  1.202e-02  -174.289  < 2e-16 ***
ORIGIN_SZJESZ06       3.880e-01  4.032e-03    96.242  < 2e-16 ***
ORIGIN_SZJESZ07      -1.706e+00  9.164e-03  -186.149  < 2e-16 ***
ORIGIN_SZJESZ08      -6.742e-01  8.277e-03   -81.453  < 2e-16 ***
ORIGIN_SZJESZ09       4.884e-01  4.288e-03   113.897  < 2e-16 ***
ORIGIN_SZJESZ10      -1.967e+00  1.661e-02  -118.380  < 2e-16 ***
ORIGIN_SZJESZ11      -1.960e+00  1.574e-02  -124.513  < 2e-16 ***
ORIGIN_SZJWSZ01       2.155e-01  5.535e-03    38.923  < 2e-16 ***
ORIGIN_SZJWSZ02       8.774e-01  3.872e-03   226.622  < 2e-16 ***
ORIGIN_SZJWSZ03       1.281e+00  3.597e-03   356.208  < 2e-16 ***
ORIGIN_SZJWSZ04       1.303e+00  3.662e-03   355.775  < 2e-16 ***
ORIGIN_SZJWSZ05      -1.386e+00  1.029e-02  -134.681  < 2e-16 ***
ORIGIN_SZJWSZ06      -1.036e+00  8.698e-03  -119.060  < 2e-16 ***
ORIGIN_SZJWSZ07      -2.567e+00  2.130e-02  -120.517  < 2e-16 ***
ORIGIN_SZJWSZ08       1.939e+00  3.507e-03   552.937  < 2e-16 ***
ORIGIN_SZJWSZ09       1.986e+00  3.314e-03   599.270  < 2e-16 ***
ORIGIN_SZKLSZ01       2.098e-01  3.982e-03    52.698  < 2e-16 ***
ORIGIN_SZKLSZ02      -4.624e-01  4.965e-03   -93.122  < 2e-16 ***
ORIGIN_SZKLSZ03      -4.532e-01  4.989e-03   -90.839  < 2e-16 ***
ORIGIN_SZKLSZ04      -1.618e+00  6.990e-03  -231.532  < 2e-16 ***
ORIGIN_SZKLSZ05      -9.205e-01  6.637e-03  -138.693  < 2e-16 ***
ORIGIN_SZKLSZ06      -6.329e-01  4.650e-03  -136.125  < 2e-16 ***
ORIGIN_SZKLSZ07      -1.030e+00  6.132e-03  -167.957  < 2e-16 ***
ORIGIN_SZKLSZ08      -8.334e-01  5.309e-03  -156.983  < 2e-16 ***
ORIGIN_SZKLSZ09      -1.617e+00  6.758e-03  -239.352  < 2e-16 ***
ORIGIN_SZLKSZ01      -3.116e+00  3.162e-02   -98.557  < 2e-16 ***
ORIGIN_SZMDSZ01      -2.337e+00  2.155e-02  -108.442  < 2e-16 ***
ORIGIN_SZMDSZ02      -1.184e+00  1.005e-02  -117.751  < 2e-16 ***
ORIGIN_SZMDSZ03      -1.848e+00  1.329e-02  -139.034  < 2e-16 ***
ORIGIN_SZMPSZ01      -9.138e-01  6.558e-03  -139.351  < 2e-16 ***
ORIGIN_SZMPSZ02      -4.291e-01  5.472e-03   -78.427  < 2e-16 ***
ORIGIN_SZMPSZ03       2.287e-01  4.325e-03    52.885  < 2e-16 ***
ORIGIN_SZMSSZ01      -6.413e+00  3.780e-01   -16.966  < 2e-16 ***
ORIGIN_SZMUSZ01      -1.333e+00  5.854e-03  -227.763  < 2e-16 ***
ORIGIN_SZMUSZ02      -3.274e+00  1.446e-02  -226.445  < 2e-16 ***
ORIGIN_SZMUSZ03      -1.924e+00  6.893e-03  -279.052  < 2e-16 ***
ORIGIN_SZNTSZ01      -2.341e+00  2.489e-02   -94.082  < 2e-16 ***
ORIGIN_SZNTSZ02      -2.554e+00  1.304e-02  -195.840  < 2e-16 ***
ORIGIN_SZNTSZ03      -8.610e-01  5.954e-03  -144.595  < 2e-16 ***
ORIGIN_SZNTSZ05      -3.240e+00  3.814e-02   -84.959  < 2e-16 ***
ORIGIN_SZNTSZ06      -3.455e+00  3.797e-02   -90.992  < 2e-16 ***
ORIGIN_SZNVSZ01       6.612e-01  3.623e-03   182.497  < 2e-16 ***
ORIGIN_SZNVSZ02      -4.341e-01  4.874e-03   -89.069  < 2e-16 ***
ORIGIN_SZNVSZ03      -1.085e+00  6.114e-03  -177.386  < 2e-16 ***
ORIGIN_SZNVSZ04      -1.242e+00  7.184e-03  -172.834  < 2e-16 ***
ORIGIN_SZNVSZ05      -2.502e+00  1.339e-02  -186.817  < 2e-16 ***
ORIGIN_SZORSZ01      -3.296e+00  2.826e-02  -116.641  < 2e-16 ***
ORIGIN_SZORSZ02      -1.260e+00  5.814e-03  -216.668  < 2e-16 ***
ORIGIN_SZORSZ03      -1.730e+00  6.902e-03  -250.587  < 2e-16 ***
ORIGIN_SZOTSZ01      -1.800e+00  7.239e-03  -248.664  < 2e-16 ***
ORIGIN_SZOTSZ02      -1.868e+00  8.204e-03  -227.739  < 2e-16 ***
ORIGIN_SZOTSZ03      -9.620e-01  5.390e-03  -178.461  < 2e-16 ***
ORIGIN_SZOTSZ04      -8.109e-01  8.337e-03   -97.268  < 2e-16 ***
ORIGIN_SZPGSZ01      -7.269e-01  9.280e-03   -78.337  < 2e-16 ***
ORIGIN_SZPGSZ02      -3.518e-01  5.898e-03   -59.642  < 2e-16 ***
ORIGIN_SZPGSZ03       1.122e+00  3.724e-03   301.235  < 2e-16 ***
ORIGIN_SZPGSZ04       1.239e+00  3.722e-03   332.785  < 2e-16 ***
ORIGIN_SZPGSZ05       4.408e-01  4.647e-03    94.865  < 2e-16 ***
ORIGIN_SZPLSZ01      -5.569e-01  7.851e-03   -70.934  < 2e-16 ***
ORIGIN_SZPLSZ02      -1.346e+00  1.116e-02  -120.587  < 2e-16 ***
ORIGIN_SZPLSZ03      -2.949e+00  2.942e-02  -100.221  < 2e-16 ***
ORIGIN_SZPLSZ04      -3.223e+00  3.088e-02  -104.351  < 2e-16 ***
ORIGIN_SZPLSZ05      -2.259e+00  1.781e-02  -126.838  < 2e-16 ***
ORIGIN_SZPNSZ01       1.461e+00  3.902e-03   374.548  < 2e-16 ***
ORIGIN_SZPNSZ02      -6.115e-01  9.873e-03   -61.931  < 2e-16 ***
ORIGIN_SZPNSZ03      -1.988e+00  1.704e-02  -116.646  < 2e-16 ***
ORIGIN_SZPNSZ04      -2.678e+00  2.509e-02  -106.722  < 2e-16 ***
ORIGIN_SZPNSZ05      -1.837e+00  1.801e-02  -101.992  < 2e-16 ***
ORIGIN_SZPRSZ01      -7.978e-01  9.635e-03   -82.797  < 2e-16 ***
ORIGIN_SZPRSZ02       1.154e+00  3.874e-03   297.927  < 2e-16 ***
ORIGIN_SZPRSZ03       9.379e-01  3.872e-03   242.202  < 2e-16 ***
ORIGIN_SZPRSZ04      -2.384e-01  6.187e-03   -38.542  < 2e-16 ***
ORIGIN_SZPRSZ05       1.373e+00  3.701e-03   370.991  < 2e-16 ***
ORIGIN_SZPRSZ06      -4.211e-01  6.784e-03   -62.070  < 2e-16 ***
ORIGIN_SZPRSZ07      -2.529e+00  1.662e-02  -152.170  < 2e-16 ***
ORIGIN_SZPRSZ08       1.661e-01  5.106e-03    32.534  < 2e-16 ***
ORIGIN_SZQTSZ01      -4.200e-01  5.459e-03   -76.939  < 2e-16 ***
ORIGIN_SZQTSZ02      -6.275e-01  5.072e-03  -123.710  < 2e-16 ***
ORIGIN_SZQTSZ03      -2.309e-01  4.724e-03   -48.878  < 2e-16 ***
ORIGIN_SZQTSZ04      -1.030e+00  6.044e-03  -170.393  < 2e-16 ***
ORIGIN_SZQTSZ05      -2.498e-01  4.667e-03   -53.526  < 2e-16 ***
ORIGIN_SZQTSZ06      -5.085e-01  5.256e-03   -96.738  < 2e-16 ***
ORIGIN_SZQTSZ07      -1.517e+00  7.888e-03  -192.362  < 2e-16 ***
ORIGIN_SZQTSZ08      -1.414e-01  4.706e-03   -30.039  < 2e-16 ***
ORIGIN_SZQTSZ09      -6.150e-01  5.571e-03  -110.406  < 2e-16 ***
ORIGIN_SZQTSZ10      -3.673e-01  5.312e-03   -69.147  < 2e-16 ***
ORIGIN_SZQTSZ11      -1.240e+00  7.455e-03  -166.316  < 2e-16 ***
ORIGIN_SZQTSZ12      -6.568e-01  6.315e-03  -104.002  < 2e-16 ***
ORIGIN_SZQTSZ13      -1.766e-03  4.859e-03    -0.363   0.7163    
ORIGIN_SZQTSZ14      -1.255e+00  7.114e-03  -176.406  < 2e-16 ***
ORIGIN_SZQTSZ15      -6.219e-01  8.141e-03   -76.396  < 2e-16 ***
ORIGIN_SZRCSZ01      -7.435e-01  5.320e-03  -139.774  < 2e-16 ***
ORIGIN_SZRCSZ02      -2.514e+00  1.573e-02  -159.805  < 2e-16 ***
ORIGIN_SZRCSZ03      -1.664e+00  7.375e-03  -225.655  < 2e-16 ***
ORIGIN_SZRCSZ04      -2.347e+00  1.108e-02  -211.743  < 2e-16 ***
ORIGIN_SZRCSZ05      -2.901e+00  1.372e-02  -211.521  < 2e-16 ***
ORIGIN_SZRCSZ06      -5.473e-01  7.118e-03   -76.900  < 2e-16 ***
ORIGIN_SZRCSZ08      -2.603e+00  1.616e-02  -161.101  < 2e-16 ***
ORIGIN_SZRCSZ09      -2.213e+00  1.235e-02  -179.166  < 2e-16 ***
ORIGIN_SZRCSZ10      -1.925e+00  7.010e-03  -274.597  < 2e-16 ***
ORIGIN_SZRVSZ01      -2.838e+00  1.291e-02  -219.771  < 2e-16 ***
ORIGIN_SZRVSZ02      -1.313e+00  6.699e-03  -195.923  < 2e-16 ***
ORIGIN_SZRVSZ03      -2.071e+00  9.651e-03  -214.634  < 2e-16 ***
ORIGIN_SZRVSZ04      -2.065e+00  1.386e-02  -148.974  < 2e-16 ***
ORIGIN_SZRVSZ05      -2.294e+00  1.197e-02  -191.652  < 2e-16 ***
ORIGIN_SZSBSZ01       7.942e-01  4.441e-03   178.805  < 2e-16 ***
ORIGIN_SZSBSZ02      -5.518e-01  6.484e-03   -85.095  < 2e-16 ***
ORIGIN_SZSBSZ03       9.869e-01  3.927e-03   251.293  < 2e-16 ***
ORIGIN_SZSBSZ04       7.370e-01  4.459e-03   165.265  < 2e-16 ***
ORIGIN_SZSBSZ05      -1.074e-01  5.579e-03   -19.257  < 2e-16 ***
ORIGIN_SZSBSZ06      -1.693e+00  1.377e-02  -122.952  < 2e-16 ***
ORIGIN_SZSBSZ07      -7.681e-01  9.050e-03   -84.874  < 2e-16 ***
ORIGIN_SZSBSZ08      -1.024e+00  9.537e-03  -107.393  < 2e-16 ***
ORIGIN_SZSBSZ09      -4.906e-01  7.062e-03   -69.478  < 2e-16 ***
ORIGIN_SZSESZ02       1.147e+00  3.692e-03   310.686  < 2e-16 ***
ORIGIN_SZSESZ03       1.299e+00  3.540e-03   366.921  < 2e-16 ***
ORIGIN_SZSESZ04       9.358e-01  4.035e-03   231.934  < 2e-16 ***
ORIGIN_SZSESZ05      -1.812e-01  4.954e-03   -36.567  < 2e-16 ***
ORIGIN_SZSESZ06       9.649e-01  3.853e-03   250.392  < 2e-16 ***
ORIGIN_SZSESZ07      -2.172e+00  1.411e-02  -153.935  < 2e-16 ***
ORIGIN_SZSGSZ01      -8.624e-01  7.023e-03  -122.799  < 2e-16 ***
ORIGIN_SZSGSZ02      -1.168e+00  8.296e-03  -140.773  < 2e-16 ***
ORIGIN_SZSGSZ03       2.736e-01  4.387e-03    62.367  < 2e-16 ***
ORIGIN_SZSGSZ04       3.981e-01  3.999e-03    99.544  < 2e-16 ***
ORIGIN_SZSGSZ05      -1.679e+00  8.559e-03  -196.152  < 2e-16 ***
ORIGIN_SZSGSZ06       4.900e-01  3.832e-03   127.853  < 2e-16 ***
ORIGIN_SZSGSZ07      -5.267e-01  5.073e-03  -103.823  < 2e-16 ***
ORIGIN_SZSKSZ01      -9.897e-02  6.517e-03   -15.186  < 2e-16 ***
ORIGIN_SZSKSZ02       5.041e-01  4.773e-03   105.616  < 2e-16 ***
ORIGIN_SZSKSZ03      -3.733e-01  6.199e-03   -60.226  < 2e-16 ***
ORIGIN_SZSKSZ04      -2.368e+00  2.139e-02  -110.725  < 2e-16 ***
ORIGIN_SZSKSZ05      -1.261e+00  1.226e-02  -102.784  < 2e-16 ***
ORIGIN_SZSLSZ01      -3.224e+00  2.667e-02  -120.903  < 2e-16 ***
ORIGIN_SZSLSZ04      -3.092e-01  5.910e-03   -52.319  < 2e-16 ***
ORIGIN_SZSRSZ01      -1.626e+00  7.105e-03  -228.894  < 2e-16 ***
ORIGIN_SZSRSZ02      -1.867e+00  7.262e-03  -257.111  < 2e-16 ***
ORIGIN_SZSRSZ03      -3.003e+00  1.500e-02  -200.256  < 2e-16 ***
ORIGIN_SZSVSZ01      -2.784e+00  2.696e-02  -103.257  < 2e-16 ***
ORIGIN_SZTHSZ01      -2.194e+00  4.519e-02   -48.550  < 2e-16 ***
ORIGIN_SZTHSZ03      -1.577e+00  1.254e-02  -125.771  < 2e-16 ***
ORIGIN_SZTHSZ04      -2.880e+00  2.385e-02  -120.729  < 2e-16 ***
ORIGIN_SZTHSZ06      -1.633e+00  1.069e-02  -152.815  < 2e-16 ***
ORIGIN_SZTMSZ01       9.799e-01  4.179e-03   234.480  < 2e-16 ***
ORIGIN_SZTMSZ02       2.327e+00  3.246e-03   716.835  < 2e-16 ***
ORIGIN_SZTMSZ03       1.596e+00  3.466e-03   460.420  < 2e-16 ***
ORIGIN_SZTMSZ04       1.014e+00  3.981e-03   254.821  < 2e-16 ***
ORIGIN_SZTMSZ05      -1.818e-01  6.281e-03   -28.948  < 2e-16 ***
ORIGIN_SZTNSZ01      -1.100e+00  6.091e-03  -180.541  < 2e-16 ***
ORIGIN_SZTNSZ02      -1.037e+00  5.744e-03  -180.467  < 2e-16 ***
ORIGIN_SZTNSZ03      -1.444e+00  7.342e-03  -196.638  < 2e-16 ***
ORIGIN_SZTNSZ04      -6.439e-01  5.568e-03  -115.639  < 2e-16 ***
ORIGIN_SZTPSZ01      -6.417e-01  5.261e-03  -121.956  < 2e-16 ***
ORIGIN_SZTPSZ02       5.001e-01  3.677e-03   136.004  < 2e-16 ***
ORIGIN_SZTPSZ03      -5.359e-01  5.273e-03  -101.613  < 2e-16 ***
ORIGIN_SZTPSZ04      -3.781e-01  4.909e-03   -77.033  < 2e-16 ***
ORIGIN_SZTPSZ05      -3.393e-01  5.068e-03   -66.957  < 2e-16 ***
ORIGIN_SZTPSZ06       4.384e-02  5.078e-03     8.633  < 2e-16 ***
ORIGIN_SZTPSZ07      -2.999e-01  5.087e-03   -58.961  < 2e-16 ***
ORIGIN_SZTPSZ08      -7.527e-01  6.706e-03  -112.244  < 2e-16 ***
ORIGIN_SZTPSZ09      -5.025e-01  5.393e-03   -93.162  < 2e-16 ***
ORIGIN_SZTPSZ10      -4.239e-01  5.472e-03   -77.462  < 2e-16 ***
ORIGIN_SZTPSZ11       1.840e-01  4.291e-03    42.869  < 2e-16 ***
ORIGIN_SZTPSZ12      -5.342e-01  5.392e-03   -99.061  < 2e-16 ***
ORIGIN_SZTSSZ01      -3.439e+00  3.996e-02   -86.045  < 2e-16 ***
ORIGIN_SZTSSZ02       5.225e-01  5.839e-03    89.484  < 2e-16 ***
ORIGIN_SZTSSZ03       4.400e-01  5.870e-03    74.956  < 2e-16 ***
ORIGIN_SZTSSZ04       4.226e-01  6.193e-03    68.235  < 2e-16 ***
ORIGIN_SZTSSZ05      -9.305e-01  1.118e-02   -83.212  < 2e-16 ***
ORIGIN_SZTSSZ06      -1.150e+00  1.372e-02   -83.825  < 2e-16 ***
ORIGIN_SZWCSZ01       3.935e-01  5.706e-03    68.962  < 2e-16 ***
ORIGIN_SZWCSZ02      -2.855e+00  2.539e-02  -112.419  < 2e-16 ***
ORIGIN_SZWCSZ03      -4.541e+00  1.187e-01   -38.254  < 2e-16 ***
ORIGIN_SZWDSZ01       1.437e+00  3.554e-03   404.310  < 2e-16 ***
ORIGIN_SZWDSZ02       1.062e+00  4.013e-03   264.616  < 2e-16 ***
ORIGIN_SZWDSZ03       2.180e+00  3.429e-03   635.604  < 2e-16 ***
ORIGIN_SZWDSZ04       1.175e+00  4.195e-03   280.228  < 2e-16 ***
ORIGIN_SZWDSZ05       7.164e-01  4.208e-03   170.254  < 2e-16 ***
ORIGIN_SZWDSZ06       1.280e+00  3.883e-03   329.648  < 2e-16 ***
ORIGIN_SZWDSZ07      -1.453e-02  5.857e-03    -2.480   0.0131 *  
ORIGIN_SZWDSZ08      -3.921e-01  6.666e-03   -58.828  < 2e-16 ***
ORIGIN_SZWDSZ09       1.773e+00  3.587e-03   494.384  < 2e-16 ***
ORIGIN_SZYSSZ01      -3.142e-02  4.762e-03    -6.598 4.17e-11 ***
ORIGIN_SZYSSZ02       8.925e-01  4.236e-03   210.677  < 2e-16 ***
ORIGIN_SZYSSZ03       1.856e+00  3.536e-03   524.915  < 2e-16 ***
ORIGIN_SZYSSZ04       9.673e-01  3.793e-03   255.015  < 2e-16 ***
ORIGIN_SZYSSZ05       2.627e-01  4.667e-03    56.298  < 2e-16 ***
ORIGIN_SZYSSZ06      -6.909e-01  7.531e-03   -91.734  < 2e-16 ***
ORIGIN_SZYSSZ07      -6.578e-01  7.588e-03   -86.687  < 2e-16 ***
ORIGIN_SZYSSZ08      -3.432e-02  5.264e-03    -6.519 7.06e-11 ***
ORIGIN_SZYSSZ09       1.375e+00  3.641e-03   377.806  < 2e-16 ***
log(DESTIN_AGE25_64)  2.059e-02  6.755e-05   304.776  < 2e-16 ***
log(dist)            -1.009e+00  1.439e-04 -7010.995  < 2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for poisson family taken to be 1)

    Null deviance: 100298738  on 21188  degrees of freedom
Residual deviance:  38254249  on 20878  degrees of freedom
AIC: 38388198

Number of Fisher Scoring iterations: 7

With the previously created function, I can compute the R-sqaure for this model.

# Compute R square of origin constrained SIM
CalcRSquared(orcSIM$data$TRIPS, orcSIM$fitted.values)
[1] 0.4332865

It is much better than unconstrained SIM but is still slightly worse than the generalised linear regression of 0.457.

16.4.4 Destination (Attraction) constrained SIM

To calibrate the destination constrained SIM, I will need to flip the independent variables as compared to origin constrained SIM, using destination (DESTIN_SZ) instead of origin (ORIGIN_SZ) and likewise log(ORIGIN_AG25_64) instead of log(DEST_AGE_25-64).

The general formula of destination constrained SIM is as follows:

\[ \lambda_{ij} = \exp(k + \mu \ln V_i + \alpha_i - \beta \ln d_{ij}) \]

# Calibrate destination constrained SIM
decSIM <- glm(formula = TRIPS ~ 
                DESTIN_SZ + 
                log(ORIGIN_AGE25_64) + 
                log(dist),
              family = poisson(link = "log"),
              data = SIM_data,
              na.action = na.exclude)

# Check output
summary(decSIM)

Call:
glm(formula = TRIPS ~ DESTIN_SZ + log(ORIGIN_AGE25_64) + log(dist), 
    family = poisson(link = "log"), data = SIM_data, na.action = na.exclude)

Coefficients:
                       Estimate Std. Error   z value Pr(>|z|)    
(Intercept)          13.5319761  0.0029234  4628.775  < 2e-16 ***
DESTIN_SZAMSZ02       0.0167918  0.0037928     4.427 9.54e-06 ***
DESTIN_SZAMSZ03       0.2319475  0.0035339    65.635  < 2e-16 ***
DESTIN_SZAMSZ04      -0.9975760  0.0053076  -187.954  < 2e-16 ***
DESTIN_SZAMSZ05      -0.9817146  0.0050484  -194.460  < 2e-16 ***
DESTIN_SZAMSZ06      -0.8013764  0.0048434  -165.458  < 2e-16 ***
DESTIN_SZAMSZ07      -1.8664277  0.0087108  -214.267  < 2e-16 ***
DESTIN_SZAMSZ08      -0.8455618  0.0054125  -156.223  < 2e-16 ***
DESTIN_SZAMSZ09      -0.9892781  0.0052646  -187.910  < 2e-16 ***
DESTIN_SZAMSZ10       0.4506862  0.0036043   125.042  < 2e-16 ***
DESTIN_SZAMSZ11       0.1180698  0.0059975    19.686  < 2e-16 ***
DESTIN_SZAMSZ12      -0.7865942  0.0058220  -135.107  < 2e-16 ***
DESTIN_SZBDSZ01       0.6130392  0.0032390   189.269  < 2e-16 ***
DESTIN_SZBDSZ02      -0.1227433  0.0041344   -29.688  < 2e-16 ***
DESTIN_SZBDSZ03       0.1227126  0.0036407    33.706  < 2e-16 ***
DESTIN_SZBDSZ04       1.1293528  0.0029731   379.851  < 2e-16 ***
DESTIN_SZBDSZ05       0.5334000  0.0033123   161.037  < 2e-16 ***
DESTIN_SZBDSZ06       0.1898257  0.0037326    50.857  < 2e-16 ***
DESTIN_SZBDSZ07      -0.9767668  0.0075882  -128.722  < 2e-16 ***
DESTIN_SZBDSZ08      -1.2776183  0.0074432  -171.650  < 2e-16 ***
DESTIN_SZBKSZ01      -1.1543861  0.0056246  -205.238  < 2e-16 ***
DESTIN_SZBKSZ02      -0.2799558  0.0044888   -62.368  < 2e-16 ***
DESTIN_SZBKSZ03      -0.4163999  0.0044282   -94.033  < 2e-16 ***
DESTIN_SZBKSZ04      -0.0433921  0.0040333   -10.759  < 2e-16 ***
DESTIN_SZBKSZ05      -0.5599078  0.0045187  -123.909  < 2e-16 ***
DESTIN_SZBKSZ06      -0.8025541  0.0050323  -159.480  < 2e-16 ***
DESTIN_SZBKSZ07       0.2522082  0.0034407    73.302  < 2e-16 ***
DESTIN_SZBKSZ08      -1.0727218  0.0057334  -187.101  < 2e-16 ***
DESTIN_SZBKSZ09      -0.2082187  0.0041030   -50.748  < 2e-16 ***
DESTIN_SZBLSZ01      -0.2954183  0.0059378   -49.752  < 2e-16 ***
DESTIN_SZBLSZ02       0.6603094  0.0056115   117.671  < 2e-16 ***
DESTIN_SZBLSZ03       1.5311975  0.0060045   255.006  < 2e-16 ***
DESTIN_SZBLSZ04       0.0147093  0.0112063     1.313   0.1893    
DESTIN_SZBMSZ01      -0.0207789  0.0037348    -5.564 2.64e-08 ***
DESTIN_SZBMSZ02      -0.4894000  0.0039318  -124.472  < 2e-16 ***
DESTIN_SZBMSZ03      -0.9557338  0.0048392  -197.500  < 2e-16 ***
DESTIN_SZBMSZ04      -0.6736138  0.0041564  -162.068  < 2e-16 ***
DESTIN_SZBMSZ05      -0.6134023  0.0049484  -123.959  < 2e-16 ***
DESTIN_SZBMSZ06      -1.7744760  0.0086211  -205.830  < 2e-16 ***
DESTIN_SZBMSZ07      -0.1191551  0.0036709   -32.459  < 2e-16 ***
DESTIN_SZBMSZ08      -1.1864022  0.0048790  -243.163  < 2e-16 ***
DESTIN_SZBMSZ09      -2.0825468  0.0075855  -274.545  < 2e-16 ***
DESTIN_SZBMSZ10      -1.6320024  0.0060450  -269.975  < 2e-16 ***
DESTIN_SZBMSZ11      -1.6324610  0.0060813  -268.438  < 2e-16 ***
DESTIN_SZBMSZ12      -1.0218241  0.0059304  -172.304  < 2e-16 ***
DESTIN_SZBMSZ13      -0.1855890  0.0038762   -47.879  < 2e-16 ***
DESTIN_SZBMSZ14      -1.2235957  0.0062318  -196.348  < 2e-16 ***
DESTIN_SZBMSZ15      -1.3667495  0.0059462  -229.852  < 2e-16 ***
DESTIN_SZBMSZ16      -1.5756133  0.0061364  -256.765  < 2e-16 ***
DESTIN_SZBMSZ17      -1.4423702  0.0072796  -198.138  < 2e-16 ***
DESTIN_SZBPSZ01      -0.5244651  0.0044773  -117.140  < 2e-16 ***
DESTIN_SZBPSZ02      -1.6486894  0.0075109  -219.506  < 2e-16 ***
DESTIN_SZBPSZ03      -1.3000214  0.0068596  -189.518  < 2e-16 ***
DESTIN_SZBPSZ04      -0.6795349  0.0050062  -135.738  < 2e-16 ***
DESTIN_SZBPSZ05       0.5710966  0.0032576   175.311  < 2e-16 ***
DESTIN_SZBPSZ06      -0.7993487  0.0061090  -130.848  < 2e-16 ***
DESTIN_SZBPSZ07      -0.5306457  0.0062665   -84.680  < 2e-16 ***
DESTIN_SZBSSZ01      -0.1419229  0.0038218   -37.135  < 2e-16 ***
DESTIN_SZBSSZ02      -0.7491614  0.0044259  -169.268  < 2e-16 ***
DESTIN_SZBSSZ03       0.3015135  0.0032333    93.253  < 2e-16 ***
DESTIN_SZBTSZ01       0.2441227  0.0034925    69.900  < 2e-16 ***
DESTIN_SZBTSZ02      -0.5993334  0.0054119  -110.744  < 2e-16 ***
DESTIN_SZBTSZ03      -0.1722937  0.0041744   -41.274  < 2e-16 ***
DESTIN_SZBTSZ04      -1.5617992  0.0080789  -193.317  < 2e-16 ***
DESTIN_SZBTSZ05      -0.7599773  0.0058902  -129.023  < 2e-16 ***
DESTIN_SZBTSZ06      -0.8605287  0.0052281  -164.596  < 2e-16 ***
DESTIN_SZBTSZ07      -1.8942101  0.0078748  -240.541  < 2e-16 ***
DESTIN_SZBTSZ08      -1.2820702  0.0068844  -186.228  < 2e-16 ***
DESTIN_SZCCSZ01      -0.4160366  0.0058077   -71.635  < 2e-16 ***
DESTIN_SZCHSZ01      -0.8537149  0.0073861  -115.584  < 2e-16 ***
DESTIN_SZCHSZ02       0.0405302  0.0046186     8.775  < 2e-16 ***
DESTIN_SZCHSZ03       2.0014354  0.0032285   619.928  < 2e-16 ***
DESTIN_SZCKSZ01      -0.2572841  0.0042162   -61.022  < 2e-16 ***
DESTIN_SZCKSZ02      -0.6566890  0.0048095  -136.541  < 2e-16 ***
DESTIN_SZCKSZ03       0.6866678  0.0032915   208.622  < 2e-16 ***
DESTIN_SZCKSZ04      -0.6872999  0.0052477  -130.971  < 2e-16 ***
DESTIN_SZCKSZ05      -0.4977357  0.0056110   -88.707  < 2e-16 ***
DESTIN_SZCKSZ06       0.7099744  0.0038346   185.149  < 2e-16 ***
DESTIN_SZCLSZ01       0.4611783  0.0039429   116.965  < 2e-16 ***
DESTIN_SZCLSZ02      -2.2149750  0.0108205  -204.702  < 2e-16 ***
DESTIN_SZCLSZ03      -1.0099330  0.0061938  -163.056  < 2e-16 ***
DESTIN_SZCLSZ04       0.1446405  0.0036400    39.736  < 2e-16 ***
DESTIN_SZCLSZ05      -1.1992262  0.0069904  -171.552  < 2e-16 ***
DESTIN_SZCLSZ06       0.2630380  0.0034203    76.904  < 2e-16 ***
DESTIN_SZCLSZ07      -0.5626895  0.0044296  -127.029  < 2e-16 ***
DESTIN_SZCLSZ08      -0.4318994  0.0049237   -87.718  < 2e-16 ***
DESTIN_SZCLSZ09       0.3225340  0.0055773    57.830  < 2e-16 ***
DESTIN_SZDTSZ01      -0.8829222  0.0044509  -198.371  < 2e-16 ***
DESTIN_SZDTSZ02      -0.7893793  0.0043900  -179.812  < 2e-16 ***
DESTIN_SZDTSZ03      -1.1406915  0.0055817  -204.362  < 2e-16 ***
DESTIN_SZDTSZ04      -2.1711734  0.0105297  -206.196  < 2e-16 ***
DESTIN_SZDTSZ05      -1.2397874  0.0093084  -133.191  < 2e-16 ***
DESTIN_SZDTSZ06      -1.2331107  0.0063241  -194.985  < 2e-16 ***
DESTIN_SZDTSZ07      -1.9364999  0.0183439  -105.567  < 2e-16 ***
DESTIN_SZDTSZ08      -0.6054414  0.0042494  -142.478  < 2e-16 ***
DESTIN_SZDTSZ09      -1.4039196  0.0092265  -152.162  < 2e-16 ***
DESTIN_SZDTSZ10      -1.3289214  0.0074586  -178.172  < 2e-16 ***
DESTIN_SZDTSZ11      -0.7402263  0.0045670  -162.080  < 2e-16 ***
DESTIN_SZDTSZ12      -2.3295417  0.0147971  -157.432  < 2e-16 ***
DESTIN_SZDTSZ13      -2.0315184  0.0094796  -214.303  < 2e-16 ***
DESTIN_SZGLSZ01      -0.0092902  0.0041980    -2.213   0.0269 *  
DESTIN_SZGLSZ02      -0.2705099  0.0038799   -69.721  < 2e-16 ***
DESTIN_SZGLSZ03       0.4947169  0.0032749   151.063  < 2e-16 ***
DESTIN_SZGLSZ04       0.4703262  0.0031938   147.262  < 2e-16 ***
DESTIN_SZGLSZ05       0.2433273  0.0033787    72.019  < 2e-16 ***
DESTIN_SZHGSZ01       0.4393639  0.0032561   134.935  < 2e-16 ***
DESTIN_SZHGSZ02      -0.6231353  0.0045295  -137.572  < 2e-16 ***
DESTIN_SZHGSZ03      -1.1574609  0.0054926  -210.729  < 2e-16 ***
DESTIN_SZHGSZ04      -0.2928319  0.0038420   -76.218  < 2e-16 ***
DESTIN_SZHGSZ05      -0.1755917  0.0038295   -45.852  < 2e-16 ***
DESTIN_SZHGSZ06      -0.6984402  0.0045154  -154.679  < 2e-16 ***
DESTIN_SZHGSZ07       0.2697113  0.0034511    78.152  < 2e-16 ***
DESTIN_SZHGSZ08      -0.2343835  0.0040315   -58.138  < 2e-16 ***
DESTIN_SZHGSZ09       0.2484051  0.0042082    59.029  < 2e-16 ***
DESTIN_SZHGSZ10      -3.4695547  0.0288974  -120.065  < 2e-16 ***
DESTIN_SZJESZ01      -0.1338640  0.0042003   -31.870  < 2e-16 ***
DESTIN_SZJESZ02      -0.4614152  0.0043445  -106.207  < 2e-16 ***
DESTIN_SZJESZ03      -0.5684334  0.0047021  -120.890  < 2e-16 ***
DESTIN_SZJESZ04      -0.1238527  0.0049662   -24.939  < 2e-16 ***
DESTIN_SZJESZ05      -0.7647843  0.0074365  -102.843  < 2e-16 ***
DESTIN_SZJESZ06       0.4355935  0.0034536   126.126  < 2e-16 ***
DESTIN_SZJESZ07      -0.8567853  0.0061617  -139.050  < 2e-16 ***
DESTIN_SZJESZ08      -0.4251726  0.0064345   -66.077  < 2e-16 ***
DESTIN_SZJESZ09      -0.3604438  0.0047713   -75.544  < 2e-16 ***
DESTIN_SZJESZ10       0.7220157  0.0062503   115.518  < 2e-16 ***
DESTIN_SZJESZ11       0.9659224  0.0055256   174.809  < 2e-16 ***
DESTIN_SZJWSZ01      -0.3904071  0.0054402   -71.763  < 2e-16 ***
DESTIN_SZJWSZ02      -0.3722923  0.0045833   -81.229  < 2e-16 ***
DESTIN_SZJWSZ03       0.5996900  0.0034496   173.845  < 2e-16 ***
DESTIN_SZJWSZ04       0.9929145  0.0032104   309.282  < 2e-16 ***
DESTIN_SZJWSZ05      -0.2417404  0.0051383   -47.047  < 2e-16 ***
DESTIN_SZJWSZ06       0.3734233  0.0046335    80.592  < 2e-16 ***
DESTIN_SZJWSZ07      -0.6990202  0.0189832   -36.823  < 2e-16 ***
DESTIN_SZJWSZ08       0.4180364  0.0039024   107.124  < 2e-16 ***
DESTIN_SZJWSZ09       1.5196041  0.0029079   522.571  < 2e-16 ***
DESTIN_SZKLSZ01      -0.6012425  0.0041149  -146.113  < 2e-16 ***
DESTIN_SZKLSZ02      -0.7885356  0.0047111  -167.377  < 2e-16 ***
DESTIN_SZKLSZ03      -1.1966684  0.0051723  -231.359  < 2e-16 ***
DESTIN_SZKLSZ04      -1.6837636  0.0066518  -253.131  < 2e-16 ***
DESTIN_SZKLSZ05      -1.1121267  0.0068381  -162.636  < 2e-16 ***
DESTIN_SZKLSZ06      -0.8994778  0.0044837  -200.611  < 2e-16 ***
DESTIN_SZKLSZ07      -1.0722167  0.0051024  -210.139  < 2e-16 ***
DESTIN_SZKLSZ08      -0.1040235  0.0036799   -28.268  < 2e-16 ***
DESTIN_SZKLSZ09      -1.8028528  0.0066500  -271.106  < 2e-16 ***
DESTIN_SZLKSZ01      -1.5666862  0.0197773   -79.217  < 2e-16 ***
DESTIN_SZMDSZ01      -1.3118968  0.0160120   -81.932  < 2e-16 ***
DESTIN_SZMDSZ02      -1.1030330  0.0095009  -116.098  < 2e-16 ***
DESTIN_SZMDSZ03      -2.7327519  0.0212751  -128.449  < 2e-16 ***
DESTIN_SZMPSZ01      -1.2239529  0.0066157  -185.006  < 2e-16 ***
DESTIN_SZMPSZ02      -0.8082708  0.0049437  -163.494  < 2e-16 ***
DESTIN_SZMPSZ03      -0.1228211  0.0039989   -30.714  < 2e-16 ***
DESTIN_SZMSSZ01      -3.3362771  0.0747877   -44.610  < 2e-16 ***
DESTIN_SZMUSZ01      -1.0789799  0.0048487  -222.532  < 2e-16 ***
DESTIN_SZMUSZ02      -1.4951866  0.0069812  -214.173  < 2e-16 ***
DESTIN_SZMUSZ03      -1.0259562  0.0047088  -217.881  < 2e-16 ***
DESTIN_SZNTSZ01      -2.8190222  0.0210582  -133.868  < 2e-16 ***
DESTIN_SZNTSZ02      -2.1008370  0.0090816  -231.328  < 2e-16 ***
DESTIN_SZNTSZ03      -1.2160830  0.0060652  -200.502  < 2e-16 ***
DESTIN_SZNTSZ05      -1.7901223  0.0165652  -108.065  < 2e-16 ***
DESTIN_SZNTSZ06      -2.9970912  0.0274278  -109.272  < 2e-16 ***
DESTIN_SZNVSZ01      -0.2390833  0.0036171   -66.098  < 2e-16 ***
DESTIN_SZNVSZ02      -0.4540187  0.0041346  -109.808  < 2e-16 ***
DESTIN_SZNVSZ03      -0.5806739  0.0044606  -130.178  < 2e-16 ***
DESTIN_SZNVSZ04      -2.0062112  0.0085263  -235.296  < 2e-16 ***
DESTIN_SZNVSZ05      -1.8981580  0.0077725  -244.215  < 2e-16 ***
DESTIN_SZORSZ01      -2.2557576  0.0176246  -127.989  < 2e-16 ***
DESTIN_SZORSZ02      -0.0902313  0.0036934   -24.430  < 2e-16 ***
DESTIN_SZORSZ03      -0.8661247  0.0047631  -181.841  < 2e-16 ***
DESTIN_SZOTSZ01      -1.6401146  0.0061714  -265.759  < 2e-16 ***
DESTIN_SZOTSZ02      -0.9007565  0.0053437  -168.563  < 2e-16 ***
DESTIN_SZOTSZ03      -1.4600248  0.0056500  -258.412  < 2e-16 ***
DESTIN_SZOTSZ04      -1.5153965  0.0083258  -182.012  < 2e-16 ***
DESTIN_SZPGSZ01      -2.1550984  0.0140910  -152.942  < 2e-16 ***
DESTIN_SZPGSZ02      -0.8145229  0.0055203  -147.552  < 2e-16 ***
DESTIN_SZPGSZ03       0.5947295  0.0033010   180.165  < 2e-16 ***
DESTIN_SZPGSZ04       0.0952627  0.0037662    25.294  < 2e-16 ***
DESTIN_SZPGSZ05      -0.9740800  0.0061999  -157.112  < 2e-16 ***
DESTIN_SZPLSZ01      -0.0143705  0.0059088    -2.432   0.0150 *  
DESTIN_SZPLSZ02      -1.1215894  0.0100665  -111.418  < 2e-16 ***
DESTIN_SZPLSZ03      -0.1264989  0.0082183   -15.392  < 2e-16 ***
DESTIN_SZPLSZ04      -0.2164306  0.0076017   -28.471  < 2e-16 ***
DESTIN_SZPLSZ05      -0.7193772  0.0097102   -74.085  < 2e-16 ***
DESTIN_SZPNSZ01       1.2424880  0.0042508   292.298  < 2e-16 ***
DESTIN_SZPNSZ02       1.6609442  0.0056322   294.901  < 2e-16 ***
DESTIN_SZPNSZ03       0.9245230  0.0064359   143.651  < 2e-16 ***
DESTIN_SZPNSZ04       1.7379655  0.0064485   269.515  < 2e-16 ***
DESTIN_SZPNSZ05       0.9316803  0.0092764   100.435  < 2e-16 ***
DESTIN_SZPRSZ01      -0.5598464  0.0061652   -90.807  < 2e-16 ***
DESTIN_SZPRSZ02      -0.1007064  0.0042331   -23.790  < 2e-16 ***
DESTIN_SZPRSZ03       0.8446501  0.0031869   265.040  < 2e-16 ***
DESTIN_SZPRSZ04      -0.7023098  0.0069327  -101.305  < 2e-16 ***
DESTIN_SZPRSZ05      -0.0059708  0.0039934    -1.495   0.1349    
DESTIN_SZPRSZ06       0.5972882  0.0041480   143.994  < 2e-16 ***
DESTIN_SZPRSZ07      -1.5960113  0.0103536  -154.151  < 2e-16 ***
DESTIN_SZPRSZ08      -0.7301565  0.0056082  -130.194  < 2e-16 ***
DESTIN_SZQTSZ01      -1.4502101  0.0079905  -181.492  < 2e-16 ***
DESTIN_SZQTSZ02      -1.2813349  0.0057647  -222.274  < 2e-16 ***
DESTIN_SZQTSZ03      -0.8708814  0.0052594  -165.584  < 2e-16 ***
DESTIN_SZQTSZ04      -1.0902881  0.0054843  -198.801  < 2e-16 ***
DESTIN_SZQTSZ05      -0.9588636  0.0048988  -195.733  < 2e-16 ***
DESTIN_SZQTSZ06      -1.2011542  0.0053168  -225.918  < 2e-16 ***
DESTIN_SZQTSZ07      -1.6371435  0.0088569  -184.843  < 2e-16 ***
DESTIN_SZQTSZ08       0.1925489  0.0037467    51.392  < 2e-16 ***
DESTIN_SZQTSZ09      -0.4411194  0.0048083   -91.741  < 2e-16 ***
DESTIN_SZQTSZ10      -0.2479036  0.0042113   -58.866  < 2e-16 ***
DESTIN_SZQTSZ11       0.3026852  0.0040142    75.404  < 2e-16 ***
DESTIN_SZQTSZ12      -0.2864852  0.0052343   -54.732  < 2e-16 ***
DESTIN_SZQTSZ13       0.2341588  0.0039646    59.062  < 2e-16 ***
DESTIN_SZQTSZ14      -0.0003169  0.0044237    -0.072   0.9429    
DESTIN_SZQTSZ15       0.2798212  0.0054385    51.452  < 2e-16 ***
DESTIN_SZRCSZ01      -1.0655438  0.0052103  -204.505  < 2e-16 ***
DESTIN_SZRCSZ02      -2.2412920  0.0134860  -166.194  < 2e-16 ***
DESTIN_SZRCSZ03      -1.0931496  0.0070796  -154.408  < 2e-16 ***
DESTIN_SZRCSZ04      -2.7083784  0.0107670  -251.543  < 2e-16 ***
DESTIN_SZRCSZ05      -2.4072719  0.0096294  -249.991  < 2e-16 ***
DESTIN_SZRCSZ06      -2.2079454  0.0122381  -180.416  < 2e-16 ***
DESTIN_SZRCSZ08      -2.2845085  0.0101601  -224.851  < 2e-16 ***
DESTIN_SZRCSZ09      -1.7033647  0.0093982  -181.244  < 2e-16 ***
DESTIN_SZRCSZ10      -1.1179258  0.0050257  -222.441  < 2e-16 ***
DESTIN_SZRVSZ01      -2.2094685  0.0087506  -252.493  < 2e-16 ***
DESTIN_SZRVSZ02      -2.5316202  0.0118374  -213.867  < 2e-16 ***
DESTIN_SZRVSZ03      -2.5227530  0.0103503  -243.737  < 2e-16 ***
DESTIN_SZRVSZ04      -1.8936058  0.0118022  -160.445  < 2e-16 ***
DESTIN_SZRVSZ05      -2.2591957  0.0111171  -203.218  < 2e-16 ***
DESTIN_SZSBSZ01      -0.1468109  0.0046757   -31.399  < 2e-16 ***
DESTIN_SZSBSZ02      -0.9746248  0.0059588  -163.561  < 2e-16 ***
DESTIN_SZSBSZ03       0.6352135  0.0034932   181.843  < 2e-16 ***
DESTIN_SZSBSZ04       0.0743888  0.0045091    16.498  < 2e-16 ***
DESTIN_SZSBSZ05      -0.8413827  0.0057920  -145.267  < 2e-16 ***
DESTIN_SZSBSZ06      -2.6495895  0.0219836  -120.526  < 2e-16 ***
DESTIN_SZSBSZ07      -0.6527664  0.0155913   -41.867  < 2e-16 ***
DESTIN_SZSBSZ08       1.5182976  0.0041938   362.031  < 2e-16 ***
DESTIN_SZSBSZ09       0.7935678  0.0041526   191.101  < 2e-16 ***
DESTIN_SZSESZ02      -0.1621119  0.0039540   -40.999  < 2e-16 ***
DESTIN_SZSESZ03       0.7066748  0.0031165   226.756  < 2e-16 ***
DESTIN_SZSESZ04      -0.5750009  0.0045086  -127.535  < 2e-16 ***
DESTIN_SZSESZ05      -0.1565752  0.0038440   -40.733  < 2e-16 ***
DESTIN_SZSESZ06      -0.5096637  0.0047839  -106.537  < 2e-16 ***
DESTIN_SZSESZ07      -2.7566947  0.0193270  -142.635  < 2e-16 ***
DESTIN_SZSGSZ01      -0.3909858  0.0048459   -80.684  < 2e-16 ***
DESTIN_SZSGSZ02       0.0853309  0.0042688    19.989  < 2e-16 ***
DESTIN_SZSGSZ03      -0.3550648  0.0040795   -87.037  < 2e-16 ***
DESTIN_SZSGSZ04      -0.2303256  0.0039377   -58.492  < 2e-16 ***
DESTIN_SZSGSZ05      -2.0837963  0.0076908  -270.945  < 2e-16 ***
DESTIN_SZSGSZ06       0.4722873  0.0031764   148.688  < 2e-16 ***
DESTIN_SZSGSZ07      -0.3738603  0.0040739   -91.769  < 2e-16 ***
DESTIN_SZSISZ01      -1.0366212  0.0149155   -69.500  < 2e-16 ***
DESTIN_SZSKSZ01       0.0867897  0.0058855    14.746  < 2e-16 ***
DESTIN_SZSKSZ02       0.8624059  0.0041768   206.477  < 2e-16 ***
DESTIN_SZSKSZ03       0.1012121  0.0049653    20.384  < 2e-16 ***
DESTIN_SZSKSZ04      -0.5929946  0.0123979   -47.830  < 2e-16 ***
DESTIN_SZSKSZ05       0.1401700  0.0093658    14.966  < 2e-16 ***
DESTIN_SZSLSZ01      -0.3166943  0.0065782   -48.143  < 2e-16 ***
DESTIN_SZSLSZ04      -0.4358850  0.0054113   -80.551  < 2e-16 ***
DESTIN_SZSRSZ01      -1.7658362  0.0064403  -274.184  < 2e-16 ***
DESTIN_SZSRSZ02      -1.6963056  0.0074373  -228.080  < 2e-16 ***
DESTIN_SZSRSZ03      -1.6124371  0.0067798  -237.829  < 2e-16 ***
DESTIN_SZSVSZ01      -2.2156896  0.0269489   -82.218  < 2e-16 ***
DESTIN_SZTHSZ01      -2.8006440  0.0294349   -95.147  < 2e-16 ***
DESTIN_SZTHSZ03      -1.5367133  0.0167164   -91.928  < 2e-16 ***
DESTIN_SZTHSZ04      -2.2816064  0.0178897  -127.537  < 2e-16 ***
DESTIN_SZTHSZ06      -1.3482737  0.0115037  -117.203  < 2e-16 ***
DESTIN_SZTMSZ01       0.0774190  0.0042923    18.037  < 2e-16 ***
DESTIN_SZTMSZ02       1.7871993  0.0027927   639.959  < 2e-16 ***
DESTIN_SZTMSZ03       0.7024421  0.0032451   216.463  < 2e-16 ***
DESTIN_SZTMSZ04       0.7364739  0.0033642   218.914  < 2e-16 ***
DESTIN_SZTMSZ05       0.7048940  0.0040428   174.357  < 2e-16 ***
DESTIN_SZTNSZ01      -0.6225658  0.0044551  -139.742  < 2e-16 ***
DESTIN_SZTNSZ02      -1.5113237  0.0059073  -255.838  < 2e-16 ***
DESTIN_SZTNSZ03      -1.4674552  0.0070568  -207.948  < 2e-16 ***
DESTIN_SZTNSZ04      -0.9951038  0.0054966  -181.041  < 2e-16 ***
DESTIN_SZTPSZ01      -0.6135726  0.0046111  -133.063  < 2e-16 ***
DESTIN_SZTPSZ02       0.2442119  0.0031727    76.973  < 2e-16 ***
DESTIN_SZTPSZ03      -0.5651733  0.0045904  -123.121  < 2e-16 ***
DESTIN_SZTPSZ04      -1.6056673  0.0062614  -256.441  < 2e-16 ***
DESTIN_SZTPSZ05      -0.9630062  0.0048582  -198.223  < 2e-16 ***
DESTIN_SZTPSZ06      -0.5977438  0.0054739  -109.199  < 2e-16 ***
DESTIN_SZTPSZ07      -1.8213815  0.0088310  -206.249  < 2e-16 ***
DESTIN_SZTPSZ08      -1.3162823  0.0064877  -202.889  < 2e-16 ***
DESTIN_SZTPSZ09      -0.6410718  0.0049764  -128.822  < 2e-16 ***
DESTIN_SZTPSZ10      -0.7050865  0.0059349  -118.803  < 2e-16 ***
DESTIN_SZTPSZ11      -0.3858008  0.0041409   -93.169  < 2e-16 ***
DESTIN_SZTPSZ12      -0.8578815  0.0051406  -166.884  < 2e-16 ***
DESTIN_SZTSSZ01      -0.7172064  0.0196905   -36.424  < 2e-16 ***
DESTIN_SZTSSZ02       1.1210809  0.0074311   150.864  < 2e-16 ***
DESTIN_SZTSSZ03       1.7457688  0.0055575   314.129  < 2e-16 ***
DESTIN_SZTSSZ04       1.6927966  0.0056353   300.394  < 2e-16 ***
DESTIN_SZTSSZ05       1.9380563  0.0058686   330.242  < 2e-16 ***
DESTIN_SZTSSZ06       0.9576149  0.0096946    98.778  < 2e-16 ***
DESTIN_SZWCSZ01       1.7027872  0.0037055   459.529  < 2e-16 ***
DESTIN_SZWCSZ02      -0.0626789  0.0081803    -7.662 1.83e-14 ***
DESTIN_SZWCSZ03      -1.1277080  0.0220290   -51.192  < 2e-16 ***
DESTIN_SZWDSZ01       1.7223563  0.0029499   583.867  < 2e-16 ***
DESTIN_SZWDSZ02      -0.3863906  0.0049400   -78.217  < 2e-16 ***
DESTIN_SZWDSZ03       1.2720234  0.0031005   410.261  < 2e-16 ***
DESTIN_SZWDSZ04       0.1720009  0.0044862    38.340  < 2e-16 ***
DESTIN_SZWDSZ05       0.1796788  0.0043625    41.187  < 2e-16 ***
DESTIN_SZWDSZ06       0.6674524  0.0034396   194.048  < 2e-16 ***
DESTIN_SZWDSZ07       0.4435607  0.0053544    82.841  < 2e-16 ***
DESTIN_SZWDSZ08       0.6200610  0.0051289   120.896  < 2e-16 ***
DESTIN_SZWDSZ09       0.8536490  0.0036814   231.879  < 2e-16 ***
DESTIN_SZYSSZ01       1.1556023  0.0031921   362.015  < 2e-16 ***
DESTIN_SZYSSZ02       0.1486836  0.0042025    35.380  < 2e-16 ***
DESTIN_SZYSSZ03      -0.1210199  0.0044490   -27.202  < 2e-16 ***
DESTIN_SZYSSZ04      -0.0262444  0.0041887    -6.266 3.72e-10 ***
DESTIN_SZYSSZ05      -1.5396810  0.0085529  -180.019  < 2e-16 ***
DESTIN_SZYSSZ06      -1.1632912  0.0066381  -175.246  < 2e-16 ***
DESTIN_SZYSSZ07      -0.8564919  0.0084362  -101.525  < 2e-16 ***
DESTIN_SZYSSZ08       0.8047469  0.0032867   244.853  < 2e-16 ***
DESTIN_SZYSSZ09       0.3870899  0.0034183   113.240  < 2e-16 ***
log(ORIGIN_AGE25_64)  0.2288630  0.0001068  2143.277  < 2e-16 ***
log(dist)            -1.0087044  0.0001439 -7009.078  < 2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for poisson family taken to be 1)

    Null deviance: 100298738  on 21188  degrees of freedom
Residual deviance:  36717627  on 20877  degrees of freedom
AIC: 36851578

Number of Fisher Scoring iterations: 7

Lets check the R-square for this model.

# Compute R square of destination constrained SIM
CalcRSquared(decSIM$data$TRIPS, decSIM$fitted.values)
[1] 0.53799

It seems even better than the generalized linear regression this time.

16.4.5 Doubly constrained SIM

To calibrate a doubly constrained spatial interaction model (SIM), I will need to include both origin (ORIGIN_SZ) and destination (DESTIN_SZ).

The general formula of doubly constrained SIM is as follows:

\[ \lambda_{ij} = \exp(k + \mu_i + \alpha_i - \beta \ln d_{ij}) \]

# Calibrate doubly constrained SIM
dbcSIM <- glm(formula = TRIPS ~ 
                ORIGIN_SZ + 
                DESTIN_SZ + 
                log(dist),
              family = poisson(link = "log"),
              data = SIM_data,
              na.action = na.exclude)

# Check output
summary(dbcSIM)

Call:
glm(formula = TRIPS ~ ORIGIN_SZ + DESTIN_SZ + log(dist), family = poisson(link = "log"), 
    data = SIM_data, na.action = na.exclude)

Coefficients:
                  Estimate Std. Error   z value Pr(>|z|)    
(Intercept)     15.1999071  0.0038411  3957.125  < 2e-16 ***
ORIGIN_SZAMSZ02  0.9915322  0.0038375   258.380  < 2e-16 ***
ORIGIN_SZAMSZ03  0.5459405  0.0039401   138.561  < 2e-16 ***
ORIGIN_SZAMSZ04  0.1500977  0.0044098    34.037  < 2e-16 ***
ORIGIN_SZAMSZ05  0.0312761  0.0050308     6.217 5.07e-10 ***
ORIGIN_SZAMSZ06  0.4326936  0.0045672    94.738  < 2e-16 ***
ORIGIN_SZAMSZ07 -0.7825778  0.0075844  -103.183  < 2e-16 ***
ORIGIN_SZAMSZ08 -0.6243546  0.0071001   -87.937  < 2e-16 ***
ORIGIN_SZAMSZ09  0.3740520  0.0047038    79.521  < 2e-16 ***
ORIGIN_SZAMSZ10  0.2193746  0.0043532    50.394  < 2e-16 ***
ORIGIN_SZAMSZ11 -1.5022103  0.0092960  -161.597  < 2e-16 ***
ORIGIN_SZAMSZ12 -1.5341999  0.0092151  -166.487  < 2e-16 ***
ORIGIN_SZBDSZ01  0.6933547  0.0038949   178.018  < 2e-16 ***
ORIGIN_SZBDSZ02  0.3490622  0.0044578    78.304  < 2e-16 ***
ORIGIN_SZBDSZ03  0.7413352  0.0039623   187.099  < 2e-16 ***
ORIGIN_SZBDSZ04  1.3977900  0.0034993   399.450  < 2e-16 ***
ORIGIN_SZBDSZ05  0.5420249  0.0039506   137.200  < 2e-16 ***
ORIGIN_SZBDSZ06  0.8252248  0.0040223   205.164  < 2e-16 ***
ORIGIN_SZBDSZ07 -0.7602943  0.0071774  -105.929  < 2e-16 ***
ORIGIN_SZBDSZ08 -0.6345651  0.0069423   -91.406  < 2e-16 ***
ORIGIN_SZBKSZ01 -0.0883137  0.0055472   -15.920  < 2e-16 ***
ORIGIN_SZBKSZ02  0.6137043  0.0045894   133.724  < 2e-16 ***
ORIGIN_SZBKSZ03  1.0261360  0.0042561   241.098  < 2e-16 ***
ORIGIN_SZBKSZ04  0.0290086  0.0051178     5.668 1.44e-08 ***
ORIGIN_SZBKSZ05  0.2606005  0.0047755    54.570  < 2e-16 ***
ORIGIN_SZBKSZ06  0.2777183  0.0051571    53.852  < 2e-16 ***
ORIGIN_SZBKSZ07  0.8621356  0.0039381   218.922  < 2e-16 ***
ORIGIN_SZBKSZ08  0.2931074  0.0045685    64.158  < 2e-16 ***
ORIGIN_SZBKSZ09  0.0664793  0.0048300    13.764  < 2e-16 ***
ORIGIN_SZBLSZ01 -1.8396723  0.0110174  -166.979  < 2e-16 ***
ORIGIN_SZBLSZ02 -2.9121521  0.0162227  -179.511  < 2e-16 ***
ORIGIN_SZBLSZ03 -4.9095995  0.0323514  -151.759  < 2e-16 ***
ORIGIN_SZBLSZ04 -2.2019537  0.0158402  -139.011  < 2e-16 ***
ORIGIN_SZBMSZ01  0.2642502  0.0041728    63.327  < 2e-16 ***
ORIGIN_SZBMSZ02 -1.0720760  0.0058485  -183.309  < 2e-16 ***
ORIGIN_SZBMSZ03 -0.2168564  0.0047699   -45.463  < 2e-16 ***
ORIGIN_SZBMSZ04  0.1532123  0.0042484    36.063  < 2e-16 ***
ORIGIN_SZBMSZ05 -1.1312476  0.0063520  -178.093  < 2e-16 ***
ORIGIN_SZBMSZ06 -1.4253626  0.0096680  -147.431  < 2e-16 ***
ORIGIN_SZBMSZ07 -0.3859298  0.0046971   -82.164  < 2e-16 ***
ORIGIN_SZBMSZ08 -0.3021963  0.0047130   -64.120  < 2e-16 ***
ORIGIN_SZBMSZ09 -0.8447945  0.0059745  -141.399  < 2e-16 ***
ORIGIN_SZBMSZ10 -0.9654697  0.0063721  -151.515  < 2e-16 ***
ORIGIN_SZBMSZ11 -0.6449724  0.0055785  -115.618  < 2e-16 ***
ORIGIN_SZBMSZ12 -0.9045564  0.0071090  -127.241  < 2e-16 ***
ORIGIN_SZBMSZ13 -0.0984943  0.0047108   -20.908  < 2e-16 ***
ORIGIN_SZBMSZ14 -0.3947883  0.0055640   -70.953  < 2e-16 ***
ORIGIN_SZBMSZ15 -0.0670186  0.0050384   -13.301  < 2e-16 ***
ORIGIN_SZBMSZ16 -1.0304019  0.0062676  -164.401  < 2e-16 ***
ORIGIN_SZBMSZ17 -1.5214149  0.0095595  -159.151  < 2e-16 ***
ORIGIN_SZBPSZ01  0.5918848  0.0048593   121.805  < 2e-16 ***
ORIGIN_SZBPSZ02  0.7502834  0.0053812   139.426  < 2e-16 ***
ORIGIN_SZBPSZ03  1.0497994  0.0050513   207.829  < 2e-16 ***
ORIGIN_SZBPSZ04  0.7998270  0.0043948   181.992  < 2e-16 ***
ORIGIN_SZBPSZ05  0.6344497  0.0040834   155.372  < 2e-16 ***
ORIGIN_SZBPSZ06 -0.7184362  0.0068817  -104.398  < 2e-16 ***
ORIGIN_SZBPSZ07 -0.6410213  0.0068705   -93.300  < 2e-16 ***
ORIGIN_SZBSSZ01  0.0897803  0.0045857    19.578  < 2e-16 ***
ORIGIN_SZBSSZ02  0.5177060  0.0040884   126.627  < 2e-16 ***
ORIGIN_SZBSSZ03  0.1826677  0.0040716    44.864  < 2e-16 ***
ORIGIN_SZBTSZ01  0.1143941  0.0044839    25.512  < 2e-16 ***
ORIGIN_SZBTSZ02 -0.7596921  0.0064272  -118.199  < 2e-16 ***
ORIGIN_SZBTSZ03  0.0078581  0.0047967     1.638 0.101376    
ORIGIN_SZBTSZ04 -0.5542162  0.0078264   -70.814  < 2e-16 ***
ORIGIN_SZBTSZ05 -1.3020091  0.0088150  -147.703  < 2e-16 ***
ORIGIN_SZBTSZ06 -0.5166223  0.0060186   -85.838  < 2e-16 ***
ORIGIN_SZBTSZ07 -1.4739046  0.0086314  -170.761  < 2e-16 ***
ORIGIN_SZBTSZ08 -0.8188637  0.0070822  -115.623  < 2e-16 ***
ORIGIN_SZCCSZ01 -1.4566001  0.0110387  -131.954  < 2e-16 ***
ORIGIN_SZCHSZ01 -1.1511546  0.0095567  -120.456  < 2e-16 ***
ORIGIN_SZCHSZ02 -1.0091323  0.0071330  -141.474  < 2e-16 ***
ORIGIN_SZCHSZ03 -0.6349303  0.0050675  -125.293  < 2e-16 ***
ORIGIN_SZCKSZ01  0.5862545  0.0043727   134.072  < 2e-16 ***
ORIGIN_SZCKSZ02  1.2397921  0.0044754   277.022  < 2e-16 ***
ORIGIN_SZCKSZ03  0.9544106  0.0040991   232.834  < 2e-16 ***
ORIGIN_SZCKSZ04  1.8476620  0.0042652   433.197  < 2e-16 ***
ORIGIN_SZCKSZ05  1.4217142  0.0051737   274.798  < 2e-16 ***
ORIGIN_SZCKSZ06  1.2099065  0.0054731   221.065  < 2e-16 ***
ORIGIN_SZCLSZ01 -0.5769453  0.0059477   -97.003  < 2e-16 ***
ORIGIN_SZCLSZ02 -1.3071187  0.0109631  -119.228  < 2e-16 ***
ORIGIN_SZCLSZ03 -0.2688092  0.0055806   -48.168  < 2e-16 ***
ORIGIN_SZCLSZ04  0.8057075  0.0039117   205.973  < 2e-16 ***
ORIGIN_SZCLSZ05 -1.5032026  0.0103600  -145.097  < 2e-16 ***
ORIGIN_SZCLSZ06  0.8598831  0.0037475   229.452  < 2e-16 ***
ORIGIN_SZCLSZ07 -0.0945484  0.0046487   -20.339  < 2e-16 ***
ORIGIN_SZCLSZ08  0.1685830  0.0052833    31.909  < 2e-16 ***
ORIGIN_SZCLSZ09 -2.0782601  0.0133652  -155.497  < 2e-16 ***
ORIGIN_SZDTSZ01 -1.5177479  0.0071825  -211.313  < 2e-16 ***
ORIGIN_SZDTSZ02 -1.4412957  0.0067816  -212.531  < 2e-16 ***
ORIGIN_SZDTSZ03 -2.8232111  0.0149809  -188.454  < 2e-16 ***
ORIGIN_SZDTSZ04 -4.5473293  0.0831203   -54.708  < 2e-16 ***
ORIGIN_SZDTSZ05 -3.1955067  0.0243445  -131.262  < 2e-16 ***
ORIGIN_SZDTSZ06 -3.0968326  0.0194144  -159.512  < 2e-16 ***
ORIGIN_SZDTSZ07 -1.7961514  0.0190194   -94.438  < 2e-16 ***
ORIGIN_SZDTSZ08 -2.1578198  0.0098435  -219.213  < 2e-16 ***
ORIGIN_SZDTSZ09 -2.9845675  0.0209502  -142.460  < 2e-16 ***
ORIGIN_SZDTSZ10 -1.9507307  0.0105356  -185.156  < 2e-16 ***
ORIGIN_SZDTSZ11 -2.1186970  0.0109398  -193.669  < 2e-16 ***
ORIGIN_SZDTSZ12 -3.3084532  0.0270350  -122.377  < 2e-16 ***
ORIGIN_SZDTSZ13 -2.1198093  0.0126303  -167.836  < 2e-16 ***
ORIGIN_SZGLSZ01 -1.4640769  0.0073543  -199.077  < 2e-16 ***
ORIGIN_SZGLSZ02  0.1870597  0.0042616    43.894  < 2e-16 ***
ORIGIN_SZGLSZ03  0.0024448  0.0042456     0.576 0.564716    
ORIGIN_SZGLSZ04  0.9755121  0.0036050   270.600  < 2e-16 ***
ORIGIN_SZGLSZ05  0.5916150  0.0038113   155.228  < 2e-16 ***
ORIGIN_SZHGSZ01  0.1415108  0.0041985    33.705  < 2e-16 ***
ORIGIN_SZHGSZ02  0.6532600  0.0040314   162.043  < 2e-16 ***
ORIGIN_SZHGSZ03  0.4005506  0.0044027    90.978  < 2e-16 ***
ORIGIN_SZHGSZ04  0.9410951  0.0037639   250.032  < 2e-16 ***
ORIGIN_SZHGSZ05  1.2614729  0.0037176   339.322  < 2e-16 ***
ORIGIN_SZHGSZ06  0.1839934  0.0044258    41.573  < 2e-16 ***
ORIGIN_SZHGSZ07  0.5969164  0.0038971   153.171  < 2e-16 ***
ORIGIN_SZHGSZ08  0.1126282  0.0044590    25.259  < 2e-16 ***
ORIGIN_SZHGSZ09 -0.8628496  0.0061992  -139.188  < 2e-16 ***
ORIGIN_SZHGSZ10 -3.3887988  0.0386181   -87.752  < 2e-16 ***
ORIGIN_SZJESZ01  0.5275335  0.0044054   119.746  < 2e-16 ***
ORIGIN_SZJESZ02  0.3608775  0.0043963    82.087  < 2e-16 ***
ORIGIN_SZJESZ03  0.2981338  0.0046180    64.559  < 2e-16 ***
ORIGIN_SZJESZ04 -0.9640666  0.0071627  -134.596  < 2e-16 ***
ORIGIN_SZJESZ05 -2.0025807  0.0121405  -164.950  < 2e-16 ***
ORIGIN_SZJESZ06  0.2914311  0.0042418    68.705  < 2e-16 ***
ORIGIN_SZJESZ07 -1.6629057  0.0092689  -179.407  < 2e-16 ***
ORIGIN_SZJESZ08 -0.7484714  0.0086390   -86.638  < 2e-16 ***
ORIGIN_SZJESZ09  0.4110434  0.0045994    89.368  < 2e-16 ***
ORIGIN_SZJESZ10 -2.7575422  0.0172464  -159.891  < 2e-16 ***
ORIGIN_SZJESZ11 -2.9663269  0.0163303  -181.646  < 2e-16 ***
ORIGIN_SZJWSZ01  0.4687678  0.0059492    78.795  < 2e-16 ***
ORIGIN_SZJWSZ02  0.9705535  0.0041073   236.298  < 2e-16 ***
ORIGIN_SZJWSZ03  1.2316748  0.0039038   315.509  < 2e-16 ***
ORIGIN_SZJWSZ04  0.9397664  0.0040281   233.302  < 2e-16 ***
ORIGIN_SZJWSZ05 -1.6480856  0.0104785  -157.283  < 2e-16 ***
ORIGIN_SZJWSZ06 -1.2429625  0.0089470  -138.924  < 2e-16 ***
ORIGIN_SZJWSZ07 -2.2886752  0.0217756  -105.103  < 2e-16 ***
ORIGIN_SZJWSZ08  1.9572281  0.0039391   496.878  < 2e-16 ***
ORIGIN_SZJWSZ09  1.5497800  0.0036573   423.751  < 2e-16 ***
ORIGIN_SZKLSZ01  0.3028599  0.0040853    74.133  < 2e-16 ***
ORIGIN_SZKLSZ02 -0.3592514  0.0050640   -70.943  < 2e-16 ***
ORIGIN_SZKLSZ03 -0.3665571  0.0050790   -72.171  < 2e-16 ***
ORIGIN_SZKLSZ04 -1.3306775  0.0070493  -188.768  < 2e-16 ***
ORIGIN_SZKLSZ05 -0.6377843  0.0068139   -93.600  < 2e-16 ***
ORIGIN_SZKLSZ06 -0.3764310  0.0047419   -79.383  < 2e-16 ***
ORIGIN_SZKLSZ07 -0.8171896  0.0062230  -131.317  < 2e-16 ***
ORIGIN_SZKLSZ08 -0.7576831  0.0054082  -140.099  < 2e-16 ***
ORIGIN_SZKLSZ09 -1.2766253  0.0068207  -187.170  < 2e-16 ***
ORIGIN_SZLKSZ01 -2.4416684  0.0322208   -75.779  < 2e-16 ***
ORIGIN_SZMDSZ01 -1.4298089  0.0230585   -62.008  < 2e-16 ***
ORIGIN_SZMDSZ02 -1.0512485  0.0103599  -101.473  < 2e-16 ***
ORIGIN_SZMDSZ03 -1.3650799  0.0136453  -100.041  < 2e-16 ***
ORIGIN_SZMPSZ01 -0.8222832  0.0066772  -123.148  < 2e-16 ***
ORIGIN_SZMPSZ02 -0.4930735  0.0055822   -88.330  < 2e-16 ***
ORIGIN_SZMPSZ03  0.1206676  0.0044729    26.977  < 2e-16 ***
ORIGIN_SZMSSZ01 -6.1448907  0.3783240   -16.242  < 2e-16 ***
ORIGIN_SZMUSZ01 -1.0357465  0.0059323  -174.593  < 2e-16 ***
ORIGIN_SZMUSZ02 -2.8753850  0.0145064  -198.215  < 2e-16 ***
ORIGIN_SZMUSZ03 -1.6027106  0.0069588  -230.314  < 2e-16 ***
ORIGIN_SZNTSZ01 -2.3258427  0.0249185   -93.338  < 2e-16 ***
ORIGIN_SZNTSZ02 -2.2356147  0.0130994  -170.666  < 2e-16 ***
ORIGIN_SZNTSZ03 -0.6006927  0.0060806   -98.788  < 2e-16 ***
ORIGIN_SZNTSZ05 -2.7454600  0.0381994   -71.872  < 2e-16 ***
ORIGIN_SZNTSZ06 -2.8527612  0.0380950   -74.885  < 2e-16 ***
ORIGIN_SZNVSZ01  0.7867941  0.0037384   210.462  < 2e-16 ***
ORIGIN_SZNVSZ02 -0.3211425  0.0049912   -64.342  < 2e-16 ***
ORIGIN_SZNVSZ03 -0.9846200  0.0062096  -158.563  < 2e-16 ***
ORIGIN_SZNVSZ04 -1.0429028  0.0072490  -143.868  < 2e-16 ***
ORIGIN_SZNVSZ05 -2.2875679  0.0134296  -170.337  < 2e-16 ***
ORIGIN_SZORSZ01 -3.0093493  0.0283014  -106.332  < 2e-16 ***
ORIGIN_SZORSZ02 -1.0826302  0.0059205  -182.861  < 2e-16 ***
ORIGIN_SZORSZ03 -1.4430368  0.0069826  -206.661  < 2e-16 ***
ORIGIN_SZOTSZ01 -1.4138143  0.0073317  -192.835  < 2e-16 ***
ORIGIN_SZOTSZ02 -1.5832107  0.0083193  -190.307  < 2e-16 ***
ORIGIN_SZOTSZ03 -0.6817735  0.0055117  -123.697  < 2e-16 ***
ORIGIN_SZOTSZ04 -0.5769425  0.0084627   -68.175  < 2e-16 ***
ORIGIN_SZPGSZ01  0.4918602  0.0106117    46.351  < 2e-16 ***
ORIGIN_SZPGSZ02 -0.2535855  0.0060460   -41.943  < 2e-16 ***
ORIGIN_SZPGSZ03  0.9676637  0.0039062   247.725  < 2e-16 ***
ORIGIN_SZPGSZ04  1.2021981  0.0038906   308.998  < 2e-16 ***
ORIGIN_SZPGSZ05  0.6313102  0.0048367   130.526  < 2e-16 ***
ORIGIN_SZPLSZ01 -0.7008879  0.0082199   -85.267  < 2e-16 ***
ORIGIN_SZPLSZ02 -1.0392767  0.0114120   -91.069  < 2e-16 ***
ORIGIN_SZPLSZ03 -3.1460244  0.0299993  -104.870  < 2e-16 ***
ORIGIN_SZPLSZ04 -3.4808985  0.0311916  -111.597  < 2e-16 ***
ORIGIN_SZPLSZ05 -2.2810839  0.0181023  -126.011  < 2e-16 ***
ORIGIN_SZPNSZ01  0.8973191  0.0048920   183.425  < 2e-16 ***
ORIGIN_SZPNSZ02 -1.7900570  0.0113564  -157.625  < 2e-16 ***
ORIGIN_SZPNSZ03 -2.6608189  0.0175462  -151.646  < 2e-16 ***
ORIGIN_SZPNSZ04 -4.6380282  0.0258895  -179.147  < 2e-16 ***
ORIGIN_SZPNSZ05 -3.2786556  0.0202668  -161.775  < 2e-16 ***
ORIGIN_SZPRSZ01 -0.8037609  0.0099114   -81.095  < 2e-16 ***
ORIGIN_SZPRSZ02  0.9923745  0.0040751   243.524  < 2e-16 ***
ORIGIN_SZPRSZ03  0.4383760  0.0040685   107.750  < 2e-16 ***
ORIGIN_SZPRSZ04 -0.5009913  0.0065068   -76.995  < 2e-16 ***
ORIGIN_SZPRSZ05  1.0651605  0.0038956   273.428  < 2e-16 ***
ORIGIN_SZPRSZ06 -1.0037905  0.0070414  -142.555  < 2e-16 ***
ORIGIN_SZPRSZ07 -2.6545509  0.0167423  -158.554  < 2e-16 ***
ORIGIN_SZPRSZ08 -0.0713911  0.0052880   -13.500  < 2e-16 ***
ORIGIN_SZQTSZ01 -0.0630253  0.0056532   -11.149  < 2e-16 ***
ORIGIN_SZQTSZ02 -0.4527135  0.0051869   -87.281  < 2e-16 ***
ORIGIN_SZQTSZ03  0.0386662  0.0049026     7.887 3.10e-15 ***
ORIGIN_SZQTSZ04 -0.9527320  0.0061671  -154.486  < 2e-16 ***
ORIGIN_SZQTSZ05 -0.0318211  0.0048272    -6.592 4.34e-11 ***
ORIGIN_SZQTSZ06 -0.2858340  0.0054044   -52.889  < 2e-16 ***
ORIGIN_SZQTSZ07 -1.2914572  0.0079902  -161.629  < 2e-16 ***
ORIGIN_SZQTSZ08 -0.2915213  0.0049117   -59.353  < 2e-16 ***
ORIGIN_SZQTSZ09 -0.5801288  0.0057174  -101.467  < 2e-16 ***
ORIGIN_SZQTSZ10 -0.4703719  0.0054963   -85.579  < 2e-16 ***
ORIGIN_SZQTSZ11 -1.5005437  0.0076206  -196.905  < 2e-16 ***
ORIGIN_SZQTSZ12 -0.7578962  0.0065876  -115.049  < 2e-16 ***
ORIGIN_SZQTSZ13 -0.2490102  0.0051259   -48.579  < 2e-16 ***
ORIGIN_SZQTSZ14 -1.3967186  0.0072948  -191.467  < 2e-16 ***
ORIGIN_SZQTSZ15 -1.1921101  0.0088686  -134.419  < 2e-16 ***
ORIGIN_SZRCSZ01 -0.4780365  0.0054343   -87.967  < 2e-16 ***
ORIGIN_SZRCSZ02 -2.1522223  0.0157715  -136.463  < 2e-16 ***
ORIGIN_SZRCSZ03 -1.1376830  0.0075137  -151.414  < 2e-16 ***
ORIGIN_SZRCSZ04 -2.0998523  0.0111226  -188.792  < 2e-16 ***
ORIGIN_SZRCSZ05 -2.4737348  0.0137552  -179.840  < 2e-16 ***
ORIGIN_SZRCSZ06 -0.1484671  0.0072307   -20.533  < 2e-16 ***
ORIGIN_SZRCSZ08 -2.2917415  0.0162442  -141.081  < 2e-16 ***
ORIGIN_SZRCSZ09 -1.7531756  0.0124619  -140.683  < 2e-16 ***
ORIGIN_SZRCSZ10 -1.5786376  0.0070864  -222.772  < 2e-16 ***
ORIGIN_SZRVSZ01 -2.4898986  0.0129726  -191.935  < 2e-16 ***
ORIGIN_SZRVSZ02 -0.8417995  0.0068297  -123.256  < 2e-16 ***
ORIGIN_SZRVSZ03 -1.4346434  0.0097511  -147.126  < 2e-16 ***
ORIGIN_SZRVSZ04 -1.7082240  0.0139212  -122.707  < 2e-16 ***
ORIGIN_SZRVSZ05 -1.7513661  0.0121335  -144.342  < 2e-16 ***
ORIGIN_SZSBSZ01  0.9754567  0.0049247   198.074  < 2e-16 ***
ORIGIN_SZSBSZ02 -0.5628799  0.0066575   -84.549  < 2e-16 ***
ORIGIN_SZSBSZ03  0.6616685  0.0042705   154.938  < 2e-16 ***
ORIGIN_SZSBSZ04  0.4253573  0.0049524    85.889  < 2e-16 ***
ORIGIN_SZSBSZ05  0.0103021  0.0058324     1.766 0.077334 .  
ORIGIN_SZSBSZ06 -0.9730293  0.0143338   -67.884  < 2e-16 ***
ORIGIN_SZSBSZ07  0.0366673  0.0098280     3.731 0.000191 ***
ORIGIN_SZSBSZ08 -1.9716652  0.0099961  -197.244  < 2e-16 ***
ORIGIN_SZSBSZ09 -1.0257192  0.0074185  -138.266  < 2e-16 ***
ORIGIN_SZSESZ02  1.2003983  0.0038187   314.346  < 2e-16 ***
ORIGIN_SZSESZ03  1.1116771  0.0036759   302.424  < 2e-16 ***
ORIGIN_SZSESZ04  1.0576059  0.0042091   251.266  < 2e-16 ***
ORIGIN_SZSESZ05 -0.2013289  0.0050541   -39.835  < 2e-16 ***
ORIGIN_SZSESZ06  1.1326368  0.0039889   283.950  < 2e-16 ***
ORIGIN_SZSESZ07 -1.8619033  0.0141423  -131.655  < 2e-16 ***
ORIGIN_SZSGSZ01 -0.8265775  0.0072006  -114.792  < 2e-16 ***
ORIGIN_SZSGSZ02 -1.2855959  0.0083996  -153.055  < 2e-16 ***
ORIGIN_SZSGSZ03  0.2726552  0.0044852    60.790  < 2e-16 ***
ORIGIN_SZSGSZ04  0.4106394  0.0040894   100.415  < 2e-16 ***
ORIGIN_SZSGSZ05 -1.5830761  0.0085928  -184.233  < 2e-16 ***
ORIGIN_SZSGSZ06  0.3447324  0.0039288    87.745  < 2e-16 ***
ORIGIN_SZSGSZ07 -0.5230863  0.0051521  -101.529  < 2e-16 ***
ORIGIN_SZSKSZ01 -0.0708352  0.0070461   -10.053  < 2e-16 ***
ORIGIN_SZSKSZ02  0.2663741  0.0053515    49.776  < 2e-16 ***
ORIGIN_SZSKSZ03 -0.3245853  0.0064849   -50.052  < 2e-16 ***
ORIGIN_SZSKSZ04 -1.9682010  0.0226854   -86.761  < 2e-16 ***
ORIGIN_SZSKSZ05 -1.2037861  0.0141172   -85.271  < 2e-16 ***
ORIGIN_SZSLSZ01 -3.0067731  0.0268121  -112.142  < 2e-16 ***
ORIGIN_SZSLSZ04 -0.2408349  0.0060503   -39.805  < 2e-16 ***
ORIGIN_SZSRSZ01 -1.2025265  0.0072145  -166.682  < 2e-16 ***
ORIGIN_SZSRSZ02 -1.4810758  0.0073378  -201.842  < 2e-16 ***
ORIGIN_SZSRSZ03 -2.4986726  0.0150646  -165.864  < 2e-16 ***
ORIGIN_SZSVSZ01 -2.4468090  0.0356146   -68.703  < 2e-16 ***
ORIGIN_SZTHSZ01 -2.6433817  0.0452493   -58.418  < 2e-16 ***
ORIGIN_SZTHSZ03 -0.9313859  0.0129174   -72.103  < 2e-16 ***
ORIGIN_SZTHSZ04 -1.9528220  0.0240275   -81.275  < 2e-16 ***
ORIGIN_SZTHSZ06 -1.1556098  0.0108689  -106.322  < 2e-16 ***
ORIGIN_SZTMSZ01  0.6084055  0.0044135   137.852  < 2e-16 ***
ORIGIN_SZTMSZ02  1.5436121  0.0034453   448.031  < 2e-16 ***
ORIGIN_SZTMSZ03  1.1852360  0.0036421   325.425  < 2e-16 ***
ORIGIN_SZTMSZ04  0.3951167  0.0042346    93.308  < 2e-16 ***
ORIGIN_SZTMSZ05 -0.9556999  0.0066658  -143.373  < 2e-16 ***
ORIGIN_SZTNSZ01 -0.8834358  0.0062125  -142.202  < 2e-16 ***
ORIGIN_SZTNSZ02 -0.7351312  0.0058511  -125.639  < 2e-16 ***
ORIGIN_SZTNSZ03 -1.1491032  0.0074573  -154.092  < 2e-16 ***
ORIGIN_SZTNSZ04 -0.3590746  0.0057140   -62.841  < 2e-16 ***
ORIGIN_SZTPSZ01 -0.5010324  0.0053698   -93.305  < 2e-16 ***
ORIGIN_SZTPSZ02  0.5048187  0.0037790   133.586  < 2e-16 ***
ORIGIN_SZTPSZ03 -0.5180138  0.0053842   -96.210  < 2e-16 ***
ORIGIN_SZTPSZ04 -0.2086734  0.0050049   -41.693  < 2e-16 ***
ORIGIN_SZTPSZ05 -0.1074656  0.0051891   -20.710  < 2e-16 ***
ORIGIN_SZTPSZ06  0.4586729  0.0055576    82.530  < 2e-16 ***
ORIGIN_SZTPSZ07 -0.1199714  0.0052051   -23.049  < 2e-16 ***
ORIGIN_SZTPSZ08 -0.5074852  0.0068250   -74.357  < 2e-16 ***
ORIGIN_SZTPSZ09 -0.5392473  0.0055201   -97.689  < 2e-16 ***
ORIGIN_SZTPSZ10 -0.3111562  0.0056043   -55.521  < 2e-16 ***
ORIGIN_SZTPSZ11  0.1676004  0.0044219    37.903  < 2e-16 ***
ORIGIN_SZTPSZ12 -0.5344206  0.0054843   -97.446  < 2e-16 ***
ORIGIN_SZTSSZ01 -3.2942604  0.0410073   -80.333  < 2e-16 ***
ORIGIN_SZTSSZ02  0.0886812  0.0080703    10.989  < 2e-16 ***
ORIGIN_SZTSSZ03 -0.2363144  0.0081359   -29.046  < 2e-16 ***
ORIGIN_SZTSSZ04 -0.7144742  0.0084663   -84.390  < 2e-16 ***
ORIGIN_SZTSSZ05 -2.8037139  0.0131321  -213.501  < 2e-16 ***
ORIGIN_SZTSSZ06 -3.3945573  0.0193276  -175.632  < 2e-16 ***
ORIGIN_SZWCSZ01 -0.8678171  0.0065959  -131.568  < 2e-16 ***
ORIGIN_SZWCSZ02 -2.6973891  0.0256373  -105.213  < 2e-16 ***
ORIGIN_SZWCSZ03 -4.6115565  0.1187370   -38.838  < 2e-16 ***
ORIGIN_SZWDSZ01  0.9038540  0.0038107   237.187  < 2e-16 ***
ORIGIN_SZWDSZ02  0.9422172  0.0042893   219.668  < 2e-16 ***
ORIGIN_SZWDSZ03  1.6903891  0.0038831   435.324  < 2e-16 ***
ORIGIN_SZWDSZ04  1.1333527  0.0046724   242.564  < 2e-16 ***
ORIGIN_SZWDSZ05  0.5945016  0.0045045   131.980  < 2e-16 ***
ORIGIN_SZWDSZ06  0.9826771  0.0042416   231.675  < 2e-16 ***
ORIGIN_SZWDSZ07 -0.1575232  0.0061736   -25.516  < 2e-16 ***
ORIGIN_SZWDSZ08 -0.7931466  0.0069921  -113.435  < 2e-16 ***
ORIGIN_SZWDSZ09  1.6716643  0.0040142   416.442  < 2e-16 ***
ORIGIN_SZYSSZ01 -0.4093427  0.0049649   -82.447  < 2e-16 ***
ORIGIN_SZYSSZ02  0.9221490  0.0046156   199.790  < 2e-16 ***
ORIGIN_SZYSSZ03  2.0586447  0.0038523   534.397  < 2e-16 ***
ORIGIN_SZYSSZ04  0.9294138  0.0039757   233.775  < 2e-16 ***
ORIGIN_SZYSSZ05  0.4557284  0.0047843    95.254  < 2e-16 ***
ORIGIN_SZYSSZ06 -0.5068728  0.0076868   -65.940  < 2e-16 ***
ORIGIN_SZYSSZ07 -0.4572689  0.0082899   -55.160  < 2e-16 ***
ORIGIN_SZYSSZ08 -0.4737067  0.0055040   -86.067  < 2e-16 ***
ORIGIN_SZYSSZ09  1.1781077  0.0038895   302.893  < 2e-16 ***
DESTIN_SZAMSZ02 -0.2332173  0.0038941   -59.891  < 2e-16 ***
DESTIN_SZAMSZ03  0.1053381  0.0036216    29.086  < 2e-16 ***
DESTIN_SZAMSZ04 -0.9991004  0.0053586  -186.448  < 2e-16 ***
DESTIN_SZAMSZ05 -0.8848530  0.0051151  -172.989  < 2e-16 ***
DESTIN_SZAMSZ06 -0.7481102  0.0049376  -151.513  < 2e-16 ***
DESTIN_SZAMSZ07 -1.6646236  0.0087835  -189.517  < 2e-16 ***
DESTIN_SZAMSZ08 -0.7232492  0.0055230  -130.952  < 2e-16 ***
DESTIN_SZAMSZ09 -1.0122575  0.0053562  -188.988  < 2e-16 ***
DESTIN_SZAMSZ10  0.1537791  0.0036945    41.624  < 2e-16 ***
DESTIN_SZAMSZ11 -0.0447198  0.0062129    -7.198 6.12e-13 ***
DESTIN_SZAMSZ12 -0.6421683  0.0058839  -109.140  < 2e-16 ***
DESTIN_SZBDSZ01  0.5058493  0.0034094   148.367  < 2e-16 ***
DESTIN_SZBDSZ02 -0.2717119  0.0043145   -62.976  < 2e-16 ***
DESTIN_SZBDSZ03 -0.0120332  0.0038108    -3.158 0.001590 ** 
DESTIN_SZBDSZ04  0.7803347  0.0031666   246.427  < 2e-16 ***
DESTIN_SZBDSZ05  0.5173032  0.0034863   148.384  < 2e-16 ***
DESTIN_SZBDSZ06  0.0154145  0.0039635     3.889 0.000101 ***
DESTIN_SZBDSZ07 -0.6918517  0.0078904   -87.682  < 2e-16 ***
DESTIN_SZBDSZ08 -1.2918718  0.0075749  -170.547  < 2e-16 ***
DESTIN_SZBKSZ01 -1.3974144  0.0057919  -241.269  < 2e-16 ***
DESTIN_SZBKSZ02 -0.5518467  0.0047951  -115.086  < 2e-16 ***
DESTIN_SZBKSZ03 -0.8529731  0.0047189  -180.758  < 2e-16 ***
DESTIN_SZBKSZ04 -0.2714960  0.0042971   -63.181  < 2e-16 ***
DESTIN_SZBKSZ05 -0.6157950  0.0047352  -130.047  < 2e-16 ***
DESTIN_SZBKSZ06 -1.0440527  0.0052560  -198.640  < 2e-16 ***
DESTIN_SZBKSZ07  0.0065723  0.0036945     1.779 0.075253 .  
DESTIN_SZBKSZ08 -1.1893742  0.0059193  -200.932  < 2e-16 ***
DESTIN_SZBKSZ09 -0.2163686  0.0043209   -50.075  < 2e-16 ***
DESTIN_SZBLSZ01 -0.7414429  0.0061120  -121.310  < 2e-16 ***
DESTIN_SZBLSZ02  0.3444230  0.0058769    58.606  < 2e-16 ***
DESTIN_SZBLSZ03  1.6121676  0.0063877   252.387  < 2e-16 ***
DESTIN_SZBLSZ04 -0.5006334  0.0118243   -42.339  < 2e-16 ***
DESTIN_SZBMSZ01  0.1389169  0.0039066    35.559  < 2e-16 ***
DESTIN_SZBMSZ02 -0.0952267  0.0040569   -23.473  < 2e-16 ***
DESTIN_SZBMSZ03 -0.5152067  0.0049850  -103.352  < 2e-16 ***
DESTIN_SZBMSZ04 -0.2622231  0.0043201   -60.698  < 2e-16 ***
DESTIN_SZBMSZ05 -0.2947874  0.0050816   -58.010  < 2e-16 ***
DESTIN_SZBMSZ06 -1.1956385  0.0087573  -136.531  < 2e-16 ***
DESTIN_SZBMSZ07  0.2620893  0.0038243    68.532  < 2e-16 ***
DESTIN_SZBMSZ08 -0.7233463  0.0049997  -144.678  < 2e-16 ***
DESTIN_SZBMSZ09 -1.4801415  0.0076791  -192.750  < 2e-16 ***
DESTIN_SZBMSZ10 -1.0568332  0.0061534  -171.749  < 2e-16 ***
DESTIN_SZBMSZ11 -1.1755381  0.0061881  -189.967  < 2e-16 ***
DESTIN_SZBMSZ12 -0.4756214  0.0061485   -77.356  < 2e-16 ***
DESTIN_SZBMSZ13  0.1640918  0.0040753    40.265  < 2e-16 ***
DESTIN_SZBMSZ14 -0.7245876  0.0064607  -112.153  < 2e-16 ***
DESTIN_SZBMSZ15 -0.9374745  0.0061199  -153.186  < 2e-16 ***
DESTIN_SZBMSZ16 -1.1297224  0.0062235  -181.526  < 2e-16 ***
DESTIN_SZBMSZ17 -1.1496478  0.0073709  -155.971  < 2e-16 ***
DESTIN_SZBPSZ01 -0.9160863  0.0047624  -192.358  < 2e-16 ***
DESTIN_SZBPSZ02 -1.9731256  0.0078054  -252.788  < 2e-16 ***
DESTIN_SZBPSZ03 -1.7606427  0.0072516  -242.792  < 2e-16 ***
DESTIN_SZBPSZ04 -0.9986932  0.0052769  -189.257  < 2e-16 ***
DESTIN_SZBPSZ05  0.2720045  0.0035451    76.726  < 2e-16 ***
DESTIN_SZBPSZ06 -0.8102457  0.0063352  -127.897  < 2e-16 ***
DESTIN_SZBPSZ07 -0.5438293  0.0065632   -82.861  < 2e-16 ***
DESTIN_SZBSSZ01  0.0658141  0.0039354    16.723  < 2e-16 ***
DESTIN_SZBSSZ02 -0.7261582  0.0045059  -161.156  < 2e-16 ***
DESTIN_SZBSSZ03  0.4168651  0.0033193   125.588  < 2e-16 ***
DESTIN_SZBTSZ01  0.2721995  0.0036873    73.822  < 2e-16 ***
DESTIN_SZBTSZ02 -0.5251752  0.0055795   -94.126  < 2e-16 ***
DESTIN_SZBTSZ03 -0.0069795  0.0043750    -1.595 0.110645    
DESTIN_SZBTSZ04 -1.0844470  0.0083834  -129.357  < 2e-16 ***
DESTIN_SZBTSZ05 -0.3760852  0.0060799   -61.857  < 2e-16 ***
DESTIN_SZBTSZ06 -0.5516357  0.0053702  -102.721  < 2e-16 ***
DESTIN_SZBTSZ07 -1.4446318  0.0079566  -181.565  < 2e-16 ***
DESTIN_SZBTSZ08 -0.7546447  0.0070907  -106.427  < 2e-16 ***
DESTIN_SZCCSZ01 -0.3802039  0.0059751   -63.631  < 2e-16 ***
DESTIN_SZCHSZ01 -0.8746170  0.0075761  -115.444  < 2e-16 ***
DESTIN_SZCHSZ02  0.0999760  0.0048168    20.756  < 2e-16 ***
DESTIN_SZCHSZ03  1.6120781  0.0034849   462.588  < 2e-16 ***
DESTIN_SZCKSZ01 -0.6184136  0.0045074  -137.200  < 2e-16 ***
DESTIN_SZCKSZ02 -1.2375474  0.0051472  -240.429  < 2e-16 ***
DESTIN_SZCKSZ03  0.1166193  0.0036857    31.641  < 2e-16 ***
DESTIN_SZCKSZ04 -1.6245356  0.0056977  -285.123  < 2e-16 ***
DESTIN_SZCKSZ05 -1.3649438  0.0064202  -212.603  < 2e-16 ***
DESTIN_SZCKSZ06 -0.0280029  0.0051149    -5.475 4.38e-08 ***
DESTIN_SZCLSZ01  0.1912978  0.0041863    45.696  < 2e-16 ***
DESTIN_SZCLSZ02 -2.0397209  0.0109314  -186.593  < 2e-16 ***
DESTIN_SZCLSZ03 -0.8871207  0.0063921  -138.783  < 2e-16 ***
DESTIN_SZCLSZ04 -0.0131578  0.0038729    -3.397 0.000680 ***
DESTIN_SZCLSZ05 -0.9641034  0.0071434  -134.964  < 2e-16 ***
DESTIN_SZCLSZ06  0.1421506  0.0036260    39.203  < 2e-16 ***
DESTIN_SZCLSZ07 -0.4423813  0.0045961   -96.252  < 2e-16 ***
DESTIN_SZCLSZ08 -0.3693630  0.0052645   -70.161  < 2e-16 ***
DESTIN_SZCLSZ09  0.3249235  0.0059198    54.887  < 2e-16 ***
DESTIN_SZDTSZ01 -0.4712511  0.0045354  -103.906  < 2e-16 ***
DESTIN_SZDTSZ02 -0.5704531  0.0044652  -127.755  < 2e-16 ***
DESTIN_SZDTSZ03 -0.9516486  0.0056419  -168.675  < 2e-16 ***
DESTIN_SZDTSZ04 -1.8886715  0.0105685  -178.708  < 2e-16 ***
DESTIN_SZDTSZ05 -0.6553720  0.0094017   -69.707  < 2e-16 ***
DESTIN_SZDTSZ06 -1.0365903  0.0063734  -162.644  < 2e-16 ***
DESTIN_SZDTSZ07 -1.8499276  0.0184530  -100.251  < 2e-16 ***
DESTIN_SZDTSZ08 -0.2969690  0.0043333   -68.531  < 2e-16 ***
DESTIN_SZDTSZ09 -1.2998740  0.0092852  -139.994  < 2e-16 ***
DESTIN_SZDTSZ10 -1.0115386  0.0075682  -133.656  < 2e-16 ***
DESTIN_SZDTSZ11 -0.4421966  0.0046470   -95.157  < 2e-16 ***
DESTIN_SZDTSZ12 -2.1185871  0.0148380  -142.782  < 2e-16 ***
DESTIN_SZDTSZ13 -1.6194904  0.0095412  -169.736  < 2e-16 ***
DESTIN_SZGLSZ01  0.0807752  0.0043170    18.711  < 2e-16 ***
DESTIN_SZGLSZ02 -0.1534631  0.0040051   -38.317  < 2e-16 ***
DESTIN_SZGLSZ03  0.5049337  0.0033917   148.875  < 2e-16 ***
DESTIN_SZGLSZ04  0.4368105  0.0033449   130.591  < 2e-16 ***
DESTIN_SZGLSZ05  0.2343129  0.0035076    66.801  < 2e-16 ***
DESTIN_SZHGSZ01  0.2893263  0.0033666    85.941  < 2e-16 ***
DESTIN_SZHGSZ02 -0.7936346  0.0046507  -170.647  < 2e-16 ***
DESTIN_SZHGSZ03 -1.3147978  0.0055925  -235.100  < 2e-16 ***
DESTIN_SZHGSZ04 -0.5117811  0.0039611  -129.201  < 2e-16 ***
DESTIN_SZHGSZ05 -0.5529184  0.0039804  -138.909  < 2e-16 ***
DESTIN_SZHGSZ06 -0.7461524  0.0046036  -162.081  < 2e-16 ***
DESTIN_SZHGSZ07  0.1464517  0.0035763    40.951  < 2e-16 ***
DESTIN_SZHGSZ08 -0.2290082  0.0041459   -55.238  < 2e-16 ***
DESTIN_SZHGSZ09 -0.0269172  0.0043213    -6.229 4.69e-10 ***
DESTIN_SZHGSZ10 -3.5542687  0.0289310  -122.853  < 2e-16 ***
DESTIN_SZJESZ01 -0.4090180  0.0044769   -91.363  < 2e-16 ***
DESTIN_SZJESZ02 -0.6579168  0.0045540  -144.470  < 2e-16 ***
DESTIN_SZJESZ03 -0.7773446  0.0049090  -158.350  < 2e-16 ***
DESTIN_SZJESZ04 -0.3342691  0.0052130   -64.123  < 2e-16 ***
DESTIN_SZJESZ05 -0.9589457  0.0075863  -126.405  < 2e-16 ***
DESTIN_SZJESZ06  0.1916414  0.0036823    52.043  < 2e-16 ***
DESTIN_SZJESZ07 -1.0031429  0.0062914  -159.446  < 2e-16 ***
DESTIN_SZJESZ08 -0.8027742  0.0067131  -119.584  < 2e-16 ***
DESTIN_SZJESZ09 -0.4257072  0.0050653   -84.043  < 2e-16 ***
DESTIN_SZJESZ10  0.5748913  0.0066508    86.440  < 2e-16 ***
DESTIN_SZJESZ11  0.9676033  0.0059660   162.186  < 2e-16 ***
DESTIN_SZJWSZ01 -0.9426981  0.0058853  -160.180  < 2e-16 ***
DESTIN_SZJWSZ02 -0.8963200  0.0048611  -184.387  < 2e-16 ***
DESTIN_SZJWSZ03  0.0993342  0.0038224    25.988  < 2e-16 ***
DESTIN_SZJWSZ04  0.6387926  0.0035927   177.801  < 2e-16 ***
DESTIN_SZJWSZ05 -0.6250246  0.0053254  -117.368  < 2e-16 ***
DESTIN_SZJWSZ06 -0.3465058  0.0049105   -70.564  < 2e-16 ***
DESTIN_SZJWSZ07 -1.6438649  0.0195851   -83.934  < 2e-16 ***
DESTIN_SZJWSZ08 -0.6874421  0.0044423  -154.750  < 2e-16 ***
DESTIN_SZJWSZ09  0.8189854  0.0032936   248.658  < 2e-16 ***
DESTIN_SZKLSZ01 -0.4005752  0.0042306   -94.686  < 2e-16 ***
DESTIN_SZKLSZ02 -0.6179792  0.0048133  -128.391  < 2e-16 ***
DESTIN_SZKLSZ03 -0.9688373  0.0052592  -184.217  < 2e-16 ***
DESTIN_SZKLSZ04 -1.4267531  0.0067118  -212.572  < 2e-16 ***
DESTIN_SZKLSZ05 -0.8446488  0.0070244  -120.245  < 2e-16 ***
DESTIN_SZKLSZ06 -0.5493906  0.0045825  -119.889  < 2e-16 ***
DESTIN_SZKLSZ07 -0.7535917  0.0052039  -144.812  < 2e-16 ***
DESTIN_SZKLSZ08  0.0852061  0.0037860    22.505  < 2e-16 ***
DESTIN_SZKLSZ09 -1.3901101  0.0067128  -207.084  < 2e-16 ***
DESTIN_SZLKSZ01 -1.9657147  0.0201911   -97.355  < 2e-16 ***
DESTIN_SZMDSZ01 -1.7151502  0.0171489  -100.015  < 2e-16 ***
DESTIN_SZMDSZ02 -1.2583446  0.0097679  -128.825  < 2e-16 ***
DESTIN_SZMDSZ03 -2.1225727  0.0217629   -97.532  < 2e-16 ***
DESTIN_SZMPSZ01 -0.8693453  0.0067478  -128.833  < 2e-16 ***
DESTIN_SZMPSZ02 -0.6308502  0.0050562  -124.766  < 2e-16 ***
DESTIN_SZMPSZ03 -0.0056435  0.0041609    -1.356 0.175003    
DESTIN_SZMSSZ01 -1.3729359  0.0751057   -18.280  < 2e-16 ***
DESTIN_SZMUSZ01 -0.7833122  0.0049324  -158.809  < 2e-16 ***
DESTIN_SZMUSZ02 -0.9417047  0.0070679  -133.236  < 2e-16 ***
DESTIN_SZMUSZ03 -0.7395283  0.0047838  -154.591  < 2e-16 ***
DESTIN_SZNTSZ01 -2.3126968  0.0211048  -109.582  < 2e-16 ***
DESTIN_SZNTSZ02 -1.6418411  0.0091480  -179.475  < 2e-16 ***
DESTIN_SZNTSZ03 -0.9243556  0.0061955  -149.198  < 2e-16 ***
DESTIN_SZNTSZ05 -1.6413945  0.0167167   -98.189  < 2e-16 ***
DESTIN_SZNTSZ06 -2.9862157  0.0275160  -108.527  < 2e-16 ***
DESTIN_SZNVSZ01 -0.1526249  0.0037416   -40.791  < 2e-16 ***
DESTIN_SZNVSZ02 -0.1866911  0.0042598   -43.826  < 2e-16 ***
DESTIN_SZNVSZ03 -0.2710284  0.0045618   -59.412  < 2e-16 ***
DESTIN_SZNVSZ04 -1.6779802  0.0085942  -195.245  < 2e-16 ***
DESTIN_SZNVSZ05 -1.5380567  0.0078202  -196.677  < 2e-16 ***
DESTIN_SZORSZ01 -1.5043188  0.0177281   -84.855  < 2e-16 ***
DESTIN_SZORSZ02  0.2387676  0.0038205    62.496  < 2e-16 ***
DESTIN_SZORSZ03 -0.5487042  0.0048604  -112.893  < 2e-16 ***
DESTIN_SZOTSZ01 -1.0305415  0.0062687  -164.394  < 2e-16 ***
DESTIN_SZOTSZ02 -0.3370781  0.0054994   -61.294  < 2e-16 ***
DESTIN_SZOTSZ03 -1.0130722  0.0057711  -175.541  < 2e-16 ***
DESTIN_SZOTSZ04 -1.2818609  0.0083732  -153.090  < 2e-16 ***
DESTIN_SZPGSZ01 -2.3428398  0.0160092  -146.343  < 2e-16 ***
DESTIN_SZPGSZ02 -0.9084620  0.0057244  -158.699  < 2e-16 ***
DESTIN_SZPGSZ03  0.2662100  0.0035088    75.870  < 2e-16 ***
DESTIN_SZPGSZ04 -0.3360770  0.0039805   -84.430  < 2e-16 ***
DESTIN_SZPGSZ05 -1.2147081  0.0064825  -187.382  < 2e-16 ***
DESTIN_SZPLSZ01 -0.4774027  0.0062052   -76.936  < 2e-16 ***
DESTIN_SZPLSZ02 -1.5230773  0.0103036  -147.820  < 2e-16 ***
DESTIN_SZPLSZ03 -0.2269388  0.0084777   -26.769  < 2e-16 ***
DESTIN_SZPLSZ04 -0.2314288  0.0080588   -28.718  < 2e-16 ***
DESTIN_SZPLSZ05 -0.8557428  0.0099189   -86.274  < 2e-16 ***
DESTIN_SZPNSZ01 -0.1721120  0.0049800   -34.560  < 2e-16 ***
DESTIN_SZPNSZ02  0.8937286  0.0067194   133.007  < 2e-16 ***
DESTIN_SZPNSZ03 -0.0131647  0.0068564    -1.920 0.054852 .  
DESTIN_SZPNSZ04  1.7753521  0.0075477   235.217  < 2e-16 ***
DESTIN_SZPNSZ05  1.1056489  0.0108712   101.704  < 2e-16 ***
DESTIN_SZPRSZ01 -0.9285438  0.0063620  -145.951  < 2e-16 ***
DESTIN_SZPRSZ02 -0.4539805  0.0044937  -101.025  < 2e-16 ***
DESTIN_SZPRSZ03  0.6871210  0.0033827   203.128  < 2e-16 ***
DESTIN_SZPRSZ04 -0.5298919  0.0073206   -72.383  < 2e-16 ***
DESTIN_SZPRSZ05 -0.3013121  0.0042431   -71.012  < 2e-16 ***
DESTIN_SZPRSZ06  0.3599770  0.0043539    82.680  < 2e-16 ***
DESTIN_SZPRSZ07 -1.1208923  0.0104879  -106.875  < 2e-16 ***
DESTIN_SZPRSZ08 -0.7595441  0.0058016  -130.919  < 2e-16 ***
DESTIN_SZQTSZ01 -1.3083866  0.0082340  -158.900  < 2e-16 ***
DESTIN_SZQTSZ02 -0.9829166  0.0058805  -167.149  < 2e-16 ***
DESTIN_SZQTSZ03 -0.6071547  0.0054733  -110.931  < 2e-16 ***
DESTIN_SZQTSZ04 -0.6383915  0.0056183  -113.626  < 2e-16 ***
DESTIN_SZQTSZ05 -0.5536823  0.0050666  -109.280  < 2e-16 ***
DESTIN_SZQTSZ06 -0.8268095  0.0054600  -151.431  < 2e-16 ***
DESTIN_SZQTSZ07 -1.3517641  0.0089670  -150.749  < 2e-16 ***
DESTIN_SZQTSZ08  0.3934103  0.0039456    99.709  < 2e-16 ***
DESTIN_SZQTSZ09 -0.4079797  0.0049644   -82.182  < 2e-16 ***
DESTIN_SZQTSZ10 -0.0237903  0.0043822    -5.429 5.67e-08 ***
DESTIN_SZQTSZ11  0.3976969  0.0041869    94.986  < 2e-16 ***
DESTIN_SZQTSZ12 -0.0988562  0.0054781   -18.046  < 2e-16 ***
DESTIN_SZQTSZ13  0.3625297  0.0042169    85.971  < 2e-16 ***
DESTIN_SZQTSZ14  0.3304396  0.0045989    71.851  < 2e-16 ***
DESTIN_SZQTSZ15  0.4128701  0.0059234    69.702  < 2e-16 ***
DESTIN_SZRCSZ01 -0.6953502  0.0053293  -130.476  < 2e-16 ***
DESTIN_SZRCSZ02 -2.0545646  0.0135404  -151.736  < 2e-16 ***
DESTIN_SZRCSZ03 -0.8934182  0.0071962  -124.152  < 2e-16 ***
DESTIN_SZRCSZ04 -2.1705721  0.0108231  -200.550  < 2e-16 ***
DESTIN_SZRCSZ05 -2.0730502  0.0096734  -214.304  < 2e-16 ***
DESTIN_SZRCSZ06 -1.6933865  0.0122960  -137.718  < 2e-16 ***
DESTIN_SZRCSZ08 -1.5358090  0.0103018  -149.082  < 2e-16 ***
DESTIN_SZRCSZ09 -1.1812502  0.0094701  -124.734  < 2e-16 ***
DESTIN_SZRCSZ10 -0.6089679  0.0051111  -119.146  < 2e-16 ***
DESTIN_SZRVSZ01 -1.5976715  0.0088190  -181.163  < 2e-16 ***
DESTIN_SZRVSZ02 -2.1525165  0.0119212  -180.562  < 2e-16 ***
DESTIN_SZRVSZ03 -1.9507131  0.0104298  -187.032  < 2e-16 ***
DESTIN_SZRVSZ04 -1.4037579  0.0118697  -118.264  < 2e-16 ***
DESTIN_SZRVSZ05 -1.4229374  0.0112906  -126.028  < 2e-16 ***
DESTIN_SZSBSZ01 -0.6277159  0.0052328  -119.959  < 2e-16 ***
DESTIN_SZSBSZ02 -1.1412070  0.0061425  -185.787  < 2e-16 ***
DESTIN_SZSBSZ03  0.3589648  0.0038681    92.801  < 2e-16 ***
DESTIN_SZSBSZ04 -0.0709076  0.0050492   -14.043  < 2e-16 ***
DESTIN_SZSBSZ05 -1.0427480  0.0060587  -172.109  < 2e-16 ***
DESTIN_SZSBSZ06 -2.3444927  0.0228529  -102.591  < 2e-16 ***
DESTIN_SZSBSZ07 -2.1716360  0.0168611  -128.795  < 2e-16 ***
DESTIN_SZSBSZ08  0.9940071  0.0045960   216.279  < 2e-16 ***
DESTIN_SZSBSZ09  0.3853085  0.0045130    85.377  < 2e-16 ***
DESTIN_SZSESZ02 -0.5774019  0.0041260  -139.942  < 2e-16 ***
DESTIN_SZSESZ03  0.3705298  0.0032705   113.293  < 2e-16 ***
DESTIN_SZSESZ04 -0.8818473  0.0047175  -186.931  < 2e-16 ***
DESTIN_SZSESZ05 -0.2972465  0.0039562   -75.134  < 2e-16 ***
DESTIN_SZSESZ06 -0.8698024  0.0049988  -174.001  < 2e-16 ***
DESTIN_SZSESZ07 -3.1274891  0.0193622  -161.526  < 2e-16 ***
DESTIN_SZSGSZ01 -0.1963321  0.0049786   -39.435  < 2e-16 ***
DESTIN_SZSGSZ02 -0.1700883  0.0043459   -39.138  < 2e-16 ***
DESTIN_SZSGSZ03 -0.4524480  0.0041809  -108.218  < 2e-16 ***
DESTIN_SZSGSZ04 -0.2295840  0.0040411   -56.812  < 2e-16 ***
DESTIN_SZSGSZ05 -1.8766540  0.0077291  -242.802  < 2e-16 ***
DESTIN_SZSGSZ06  0.4732513  0.0032728   144.602  < 2e-16 ***
DESTIN_SZSGSZ07 -0.3157314  0.0041621   -75.859  < 2e-16 ***
DESTIN_SZSISZ01 -0.5455678  0.0150088   -36.350  < 2e-16 ***
DESTIN_SZSKSZ01 -0.6771439  0.0063703  -106.297  < 2e-16 ***
DESTIN_SZSKSZ02  0.2254683  0.0047529    47.438  < 2e-16 ***
DESTIN_SZSKSZ03 -0.4962535  0.0052887   -93.832  < 2e-16 ***
DESTIN_SZSKSZ04 -0.9962895  0.0132331   -75.288  < 2e-16 ***
DESTIN_SZSKSZ05 -0.4727211  0.0108675   -43.499  < 2e-16 ***
DESTIN_SZSLSZ01 -0.6844518  0.0066958  -102.221  < 2e-16 ***
DESTIN_SZSLSZ04 -0.8642566  0.0055529  -155.640  < 2e-16 ***
DESTIN_SZSRSZ01 -1.1258378  0.0065445  -172.028  < 2e-16 ***
DESTIN_SZSRSZ02 -1.2210342  0.0075209  -162.353  < 2e-16 ***
DESTIN_SZSRSZ03 -1.3916299  0.0068324  -203.679  < 2e-16 ***
DESTIN_SZSVSZ01 -0.8502501  0.0357682   -23.771  < 2e-16 ***
DESTIN_SZTHSZ01 -3.6862493  0.0295142  -124.897  < 2e-16 ***
DESTIN_SZTHSZ03 -2.1656897  0.0172029  -125.891  < 2e-16 ***
DESTIN_SZTHSZ04 -2.6708338  0.0180519  -147.953  < 2e-16 ***
DESTIN_SZTHSZ06 -1.8096992  0.0117190  -154.424  < 2e-16 ***
DESTIN_SZTMSZ01 -0.2650161  0.0045695   -57.996  < 2e-16 ***
DESTIN_SZTMSZ02  1.3613330  0.0030137   451.713  < 2e-16 ***
DESTIN_SZTMSZ03  0.4088507  0.0034676   117.906  < 2e-16 ***
DESTIN_SZTMSZ04  0.6607530  0.0036103   183.019  < 2e-16 ***
DESTIN_SZTMSZ05  0.7477414  0.0043234   172.950  < 2e-16 ***
DESTIN_SZTNSZ01 -0.2329343  0.0045763   -50.900  < 2e-16 ***
DESTIN_SZTNSZ02 -0.9645287  0.0060146  -160.364  < 2e-16 ***
DESTIN_SZTNSZ03 -0.9866474  0.0071782  -137.450  < 2e-16 ***
DESTIN_SZTNSZ04 -0.7708811  0.0056325  -136.862  < 2e-16 ***
DESTIN_SZTPSZ01 -0.3571909  0.0047134   -75.782  < 2e-16 ***
DESTIN_SZTPSZ02  0.3556574  0.0032813   108.388  < 2e-16 ***
DESTIN_SZTPSZ03 -0.2721489  0.0047418   -57.394  < 2e-16 ***
DESTIN_SZTPSZ04 -1.5204272  0.0063397  -239.826  < 2e-16 ***
DESTIN_SZTPSZ05 -0.9207192  0.0049711  -185.215  < 2e-16 ***
DESTIN_SZTPSZ06 -0.5985909  0.0060527   -98.897  < 2e-16 ***
DESTIN_SZTPSZ07 -1.7525701  0.0089843  -195.071  < 2e-16 ***
DESTIN_SZTPSZ08 -1.1401529  0.0066203  -172.221  < 2e-16 ***
DESTIN_SZTPSZ09 -0.3502863  0.0051273   -68.318  < 2e-16 ***
DESTIN_SZTPSZ10 -0.8499288  0.0060719  -139.978  < 2e-16 ***
DESTIN_SZTPSZ11 -0.2549491  0.0042766   -59.615  < 2e-16 ***
DESTIN_SZTPSZ12 -0.6839606  0.0052451  -130.399  < 2e-16 ***
DESTIN_SZTSSZ01 -1.2535386  0.0205589   -60.973  < 2e-16 ***
DESTIN_SZTSSZ02 -0.5129383  0.0096015   -53.423  < 2e-16 ***
DESTIN_SZTSSZ03  0.3123557  0.0076756    40.695  < 2e-16 ***
DESTIN_SZTSSZ04  0.6030653  0.0076016    79.334  < 2e-16 ***
DESTIN_SZTSSZ05  1.6523766  0.0077730   212.580  < 2e-16 ***
DESTIN_SZTSSZ06  1.8829996  0.0142804   131.859  < 2e-16 ***
DESTIN_SZWCSZ01  1.3448747  0.0043570   308.670  < 2e-16 ***
DESTIN_SZWCSZ02 -1.0146962  0.0084952  -119.443  < 2e-16 ***
DESTIN_SZWCSZ03 -1.8080822  0.0221358   -81.681  < 2e-16 ***
DESTIN_SZWDSZ01  0.8847786  0.0032457   272.598  < 2e-16 ***
DESTIN_SZWDSZ02 -1.0134375  0.0052518  -192.970  < 2e-16 ***
DESTIN_SZWDSZ03  0.5089895  0.0036337   140.077  < 2e-16 ***
DESTIN_SZWDSZ04 -0.5391818  0.0051060  -105.597  < 2e-16 ***
DESTIN_SZWDSZ05 -0.2960653  0.0047316   -62.572  < 2e-16 ***
DESTIN_SZWDSZ06  0.1082314  0.0038059    28.437  < 2e-16 ***
DESTIN_SZWDSZ07 -0.7178436  0.0057494  -124.855  < 2e-16 ***
DESTIN_SZWDSZ08 -0.1595135  0.0055042   -28.981  < 2e-16 ***
DESTIN_SZWDSZ09 -0.2931198  0.0042186   -69.483  < 2e-16 ***
DESTIN_SZYSSZ01  0.7706389  0.0034792   221.496  < 2e-16 ***
DESTIN_SZYSSZ02 -0.4208187  0.0046344   -90.804  < 2e-16 ***
DESTIN_SZYSSZ03 -1.1602553  0.0048797  -237.774  < 2e-16 ***
DESTIN_SZYSSZ04 -0.4453826  0.0044457  -100.182  < 2e-16 ***
DESTIN_SZYSSZ05 -1.8835365  0.0087245  -215.891  < 2e-16 ***
DESTIN_SZYSSZ06 -1.2555323  0.0067794  -185.197  < 2e-16 ***
DESTIN_SZYSSZ07 -0.7349207  0.0092425   -79.515  < 2e-16 ***
DESTIN_SZYSSZ08  0.7160485  0.0034728   206.185  < 2e-16 ***
DESTIN_SZYSSZ09 -0.0362770  0.0036727    -9.877  < 2e-16 ***
log(dist)       -0.9871576  0.0001519 -6497.379  < 2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for poisson family taken to be 1)

    Null deviance: 100298738  on 21188  degrees of freedom
Residual deviance:  28758680  on 20570  degrees of freedom
AIC: 28893245

Number of Fisher Scoring iterations: 7

I will check the R-square for this model as well.

# Compute R square of doubly constrained SIM
CalcRSquared(dbcSIM$data$TRIPS, dbcSIM$fitted.values)
[1] 0.599689

This seems to be an improvement over the previous models.

16.5 Model Comparison

A useful metric for comparing regression based models is Root Mean Squared Error. compare_performance() from performance package will be used to do compute this metric across the various models.

First, a list of models to be compared will be created.

# Create list of models
model_list <- list(unconstrained=uncSIM,
                   originConstrained=orcSIM,
                   destinationConstrained=decSIM,
                   doublyConstrained=dbcSIM)

Now, I can use proceed to use that list to generate metrics for the relevant models.

# Compare models
compare_performance(model_list,
                    metrics = "RMSE")
# Comparison of Model Performance Indices

Name                   | Model |     RMSE
-----------------------------------------
unconstrained          |   glm | 5059.346
originConstrained      |   glm | 4358.375
destinationConstrained |   glm | 3930.670
doublyConstrained      |   glm | 3850.306

Comparing across all models, it seems like doubly constrained model has the lowest RMSE of 3850.306.

16.6 Visualizing Fitted Values

To visualize the observed vs fitted values, I will need to extract the fitted values from each model and join it to the SIM_data dataframe. This will be done iteratively for each model.

Unconstrained SIM

# Extract fitted values
df <- as.data.frame(uncSIM$fitted.values) %>%
  round(digits = 0)

# Join to SIM_data
SIM_data <- SIM_data %>%
  cbind(df) %>%
  rename(uncTRIPS = "uncSIM$fitted.values")

Origin Constrained SIM

# Extract fitted values
df <- as.data.frame(orcSIM$fitted.values) %>%
  round(digits = 0)

# Join to SIM_data
SIM_data <- SIM_data %>%
  cbind(df) %>%
  rename(orcTRIPS = "orcSIM$fitted.values")

Destination Constained SIM

# Extract fitted values
df <- as.data.frame(decSIM$fitted.values) %>%
  round(digits = 0)

# Join to SIM_data
SIM_data <- SIM_data %>%
  cbind(df) %>%
  rename(decTRIPS = "decSIM$fitted.values")

Doubly Constrained SIM

# Extract fitted values
df <- as.data.frame(dbcSIM$fitted.values) %>%
  round(digits = 0)

# Join to SIM_data
SIM_data <- SIM_data %>%
  cbind(df) %>%
  rename(dbcTRIPS = "dbcSIM$fitted.values")

Now, I can use ggplot to visualize for all 4 models at one with ggarrange() from ggpubr package

# Plot Unconstrained SIM
unc_p <- ggplot(data = SIM_data,
                aes(x = uncTRIPS,
                    y = TRIPS)) +
  geom_point() +
  geom_smooth(method = lm)

# Plot Origin Constrained SIM
orc_p <- ggplot(data = SIM_data,
                aes(x = orcTRIPS,
                    y = TRIPS)) +
  geom_point() +
  geom_smooth(method = lm)

# Plot Destination Constrained SIM
dec_p <- ggplot(data = SIM_data,
                aes(x = decTRIPS,
                    y = TRIPS)) +
  geom_point() +
  geom_smooth(method = lm)

# Plot Doubly Constrained SIM
dbc_p <- ggplot(data = SIM_data,
                aes(x = dbcTRIPS,
                    y = TRIPS)) +
  geom_point() +
  geom_smooth(method = lm)

# Visualize them together
ggarrange(unc_p, orc_p, dec_p, dbc_p,
          ncol = 2,
          nrow = 2)
`geom_smooth()` using formula = 'y ~ x'
`geom_smooth()` using formula = 'y ~ x'
`geom_smooth()` using formula = 'y ~ x'
`geom_smooth()` using formula = 'y ~ x'